Ubuntu 下Hash校验和不符问题的解决

LinuxByte 2014-04-07 22:45:49 累计浏览 5,792 次

   在Ubuntu 下有一个问题经常会困扰大家,就是运行 apt-get update 是出现 Hash校验和不符的提示。

W: 无法下载 bzip2:/var/lib/apt/lists/partial/mirrors.163.com_ubuntu_dists_saucy-security_universe_binary-i386_Packages  Hash 校验和不符
W: 无法下载 bzip2:/var/lib/apt/lists/partial/mirrors.163.com_ubuntu_dists_saucy-security_multiverse_binary-i386_Packages  Hash 校验和不符
W: 无法下载 bzip2:/var/lib/apt/lists/partial/repo.mate-desktop.org_ubuntu_dists_saucy_main_binary-amd64_Packages  Hash 校验和不符
W: 无法下载 bzip2:/var/lib/apt/lists/partial/repo.mate-desktop.org_ubuntu_dists_saucy_main_binary-i386_Packages  Hash 校验和不符
E: Some index files failed to download. They have been ignored, or old ones used instead.

   网上搜索了一圈各种解决方法都有,不过最后判断还是网络原因,既然确定是网络造成的就有相应的解决办法。

   方法1 为APT 配置http sever。

   因为我在VPS 开了SSH SERVER,所以开SSH TUNNEL 很方便,但很可惜apt-get 只支持http 代理,所以还需要装个privoxy 把ssh tunnel 的scoks5 代理转成http 代理。

   ssh tunnel 的开启管理这里不多说,有问题可查看之前的文章:gSTM-图形ssh Tunnel管理器

   这里说一下privoxy 的安装和配置:

   a.安装

sudo apt-fast install privoxy

   b.配置

   编辑/etc/privoxy/config,让privoxy开启socks转http。在config中找到下面粗体的一行,把注释的#去掉,将端口号改为之前gSTM中设定的即可。

   listen-address localhost:8118

   #forward-socks5 / 127.0.0.1:7070

   保存启动 privoxy。

sudo /etc/init.d/privoxy start

   最后通过http 代理更新apt

sudo apt-get -o Acquire::http::proxy="http://127.0.0.1:8118/" update

   方法2. 用apt-fast 代替 apt-get 这是意外发现的,发现用了apt-fast 就不会出现 Hash 校验不符的问题了。

   apt-fast 安装配置请参看之前的文章:ppa 安装 apt-fast

同分类推荐文章

  1. NGINX Gateway Fabric 2.8: IP allow and deny lists, passive health checks, and cookie-based session persistence (2026-11-14 01:10:02)
  2. NGINX Ingress Controller 5.7: HTTP/2 to your upstreams, Opaque Secrets, and cert-manager challenges behind HTTPS redirects (2026-11-14 00:10:02)
  3. Hexo 文章一键发布到微信公众号 (2026-11-13 19:10:02)

查看更多 DevOps 文章 →

建议继续学习

  1. 检查nginx配置,重载配置以及重启的方法 (累计阅读 11,290)
  2. 为什么我认为每个穷网站开发程序员都应该用Linux[工具篇] (累计阅读 5,713)
  3. 记一下我的ubuntu升级到10.04时遇到都问题 (累计阅读 5,095)
  4. ubuntu 笔记之:如何修改dns (累计阅读 5,009)
  5. Ubuntu中apt-get列出的软件包前面的字母标识含义 (累计阅读 4,818)
  6. 解决 ubuntu 的 /etc/hosts 重启就被还原 (累计阅读 4,669)
  7. Ubuntu下Postgresql-8.4安装及配置 (累计阅读 4,462)
  8. 我和Linux (累计阅读 4,411)
  9. 在Ubuntu上使用SystemTap (累计阅读 4,226)
  10. My Lovers Tools (累计阅读 4,179)