ubuntu 16.04|解决UBUNTU下HASH校验和不符的方法

更新时间:2019-05-14    来源:Ubuntu    手机版     字体:

【www.bbyears.com--Ubuntu】

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 是一个用 axel 来加速 apt-get 软件安装的脚本,由于是多线程下载,所以加速效果还是很明显的。

添加PPA源,安装apt-fast
sudo add-apt-repository ppa:tldm217/tahutek.net
sudo apt-get update && sudo apt-get install apt-fast

使用方法:

用apt-fast 命令替代原apt-get 命令,如:
apt-fast update
apt-fast install fcitx

本文来源:http://www.bbyears.com/caozuoxitong/51097.html