apt-get 使用 Multipass 更新 Ubuntu 20.04 VM 时的哈希和不匹配
Posted
技术标签:
【中文标题】apt-get 使用 Multipass 更新 Ubuntu 20.04 VM 时的哈希和不匹配【英文标题】:Hash sum mismatch when apt-get update Ubuntu 20.04 VM with Multipass 【发布时间】:2021-01-15 02:09:21 【问题描述】:我的问题如下:
我启动了一个新的多通道 VM,它是 Ubuntu 20.04 版本(我没有指定它,只是启动)。 我的新虚拟机中的第一个命令是:
sudo apt-get update
我已经有一些错误:
Err:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
Hash Sum mismatch
Hashes of expected file:
- Filesize:1291458 [weak]
- SHA256:407e1e5f8188d9a38dec308c87203aadb16cb4ac173b729005525c4d824317c9
- SHA1:47f50537ae094c725a60e90bf5e72d563a73abb2 [weak]
- MD5Sum:05500c05300ff2f3be66040cd9d4c24b [weak]
Hashes of received file:
- SHA256:fc9c8ae3385f3b2cdb7c52c8e4ee5fa5074c843155b7ce4786b3ce3c97fe8c3f
- SHA1:59b7721865c7a9c1b313ce11f11aefa4c7951fd4 [weak]
- MD5Sum:05500c05300ff2f3be66040cd9d4c24b [weak]
- Filesize:1291458 [weak]
Last modification reported: Mon, 28 Sep 2020 16:55:59 +0000
Release file created at: Tue, 29 Sep 2020 10:33:40 +0000
Get:7 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [69.3 kB]
Err:7 http://security.ubuntu.com/ubuntu focal-security/main Translation-en
Err:5 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
Hash Sum mismatch
Hashes of expected file:
- Filesize:8627544 [weak]
- SHA256:46a746dac789bd9537aca54db1680b9dff51c248153111350382199d7d96b9d1
- SHA1:7bce310e1f03066e04653926de275118ec09b4d9 [weak]
- MD5Sum:bc50840f4e1bbb64fb3ee6e8a351d744 [weak]
Hashes of received file:
- SHA256:b2f7c8b1b81060721c7f414843b41eda6760b7814fddeefd5abbf9f2bd4a9fd0
- SHA1:b07e3465964e50b87630eea2c05faff5253efa0d [weak]
- MD5Sum:bc50840f4e1bbb64fb3ee6e8a351d744 [weak]
- Filesize:8627544 [weak]
Last modification reported: Thu, 23 Apr 2020 17:34:17 +0000
Release file created at: Thu, 23 Apr 2020 17:33:17 +0000
Get:17 http://archive.ubuntu.com/ubuntu focal/universe Translation-en [5124 kB]
Err:17 http://archive.ubuntu.com/ubuntu focal/universe Translation-en
Get:18 http://archive.ubuntu.com/ubuntu focal/universe amd64 c-n-f Metadata [265 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [144 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal/multiverse Translation-en [104 kB]
Err:20 http://archive.ubuntu.com/ubuntu focal/multiverse Translation-en
Get:21 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 c-n-f Metadata [9136 B]
Get:22 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [375 kB]
Err:22 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
Hash Sum mismatch
Hashes of expected file:
- Filesize:374700 [weak]
- SHA256:35c0b5b9cdd324a81b1ee2c31610ca9c81779dd42df1393fcc1013a877a7f01c
- SHA1:380d462e7356a2ce3e1598f4588a5e5ff0afadff [weak]
- MD5Sum:73c1f287aab2928e8db81a62677faea6 [weak]
Hashes of received file:
- SHA256:6d8b94194f56ad754d1e2b04dbaa421c81a6b539bc045713b6ad0a0d40ffd340
- SHA1:be4ec3facb19f7272637f36337a050e5826335a3 [weak]
- MD5Sum:73c1f287aab2928e8db81a62677faea6 [weak]
- Filesize:374700 [weak]
Last modification reported: Tue, 29 Sep 2020 07:15:53 +0000
Release file created at: Tue, 29 Sep 2020 10:33:56 +0000
Get:23 http://archive.ubuntu.com/ubuntu focal-updates/main Translation-en [142 kB]
Get:24 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [9876 B]
Get:25 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [43.6 kB]
Get:26 http://archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [10.8 kB]
Get:27 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [175 kB]
Get:28 http://archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [92.7 kB]
Get:29 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [5952 B]
Get:30 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [11.6 kB]
Get:31 http://archive.ubuntu.com/ubuntu focal-updates/multiverse Translation-en [3892 B]
Get:32 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 c-n-f Metadata [480 B]
Get:33 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 c-n-f Metadata [112 B]
Get:34 http://archive.ubuntu.com/ubuntu focal-backports/restricted amd64 c-n-f Metadata [116 B]
Get:35 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [3088 B]
Get:36 http://archive.ubuntu.com/ubuntu focal-backports/universe Translation-en [1448 B]
Get:37 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [224 B]
Get:38 http://archive.ubuntu.com/ubuntu focal-backports/multiverse amd64 c-n-f Metadata [116 B]
Fetched 15.9 MB in 11s (1399 kB/s)
Reading package lists... Done
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/universe/binary-amd64/by-hash/SHA256/46a746dac789bd9537aca54db1680b9dff51c248153111350382199d7d96b9d1 Hash Sum mismatch
Hashes of expected file:
- Filesize:8627544 [weak]
- SHA256:46a746dac789bd9537aca54db1680b9dff51c248153111350382199d7d96b9d1
- SHA1:7bce310e1f03066e04653926de275118ec09b4d9 [weak]
- MD5Sum:bc50840f4e1bbb64fb3ee6e8a351d744 [weak]
Hashes of received file:
- SHA256:b2f7c8b1b81060721c7f414843b41eda6760b7814fddeefd5abbf9f2bd4a9fd0
- SHA1:b07e3465964e50b87630eea2c05faff5253efa0d [weak]
- MD5Sum:bc50840f4e1bbb64fb3ee6e8a351d744 [weak]
- Filesize:8627544 [weak]
Last modification reported: Thu, 23 Apr 2020 17:34:17 +0000
Release file created at: Thu, 23 Apr 2020 17:33:17 +0000
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/universe/i18n/by-hash/SHA256/a9c6ca6ce2913776bf753ae5132c7814139880784e98672525b4059c61f209dd
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/multiverse/i18n/by-hash/SHA256/224cafd684a26e8bce3dfca4daf33b853c9273d13e4ada6161ce9ef38f1a567c
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/main/binary-amd64/by-hash/SHA256/35c0b5b9cdd324a81b1ee2c31610ca9c81779dd42df1393fcc1013a877a7f01c Hash Sum mismatch
Hashes of expected file:
- Filesize:374700 [weak]
- SHA256:35c0b5b9cdd324a81b1ee2c31610ca9c81779dd42df1393fcc1013a877a7f01c
- SHA1:380d462e7356a2ce3e1598f4588a5e5ff0afadff [weak]
- MD5Sum:73c1f287aab2928e8db81a62677faea6 [weak]
Hashes of received file:
- SHA256:6d8b94194f56ad754d1e2b04dbaa421c81a6b539bc045713b6ad0a0d40ffd340
- SHA1:be4ec3facb19f7272637f36337a050e5826335a3 [weak]
- MD5Sum:73c1f287aab2928e8db81a62677faea6 [weak]
- Filesize:374700 [weak]
Last modification reported: Tue, 29 Sep 2020 07:15:53 +0000
Release file created at: Tue, 29 Sep 2020 10:33:56 +0000
E: Failed to fetch store:/var/lib/apt/lists/partial/security.ubuntu.com_ubuntu_dists_focal-security_main_binary-amd64_Packages.xz Hash Sum mismatch
Hashes of expected file:
- Filesize:1291458 [weak]
- SHA256:407e1e5f8188d9a38dec308c87203aadb16cb4ac173b729005525c4d824317c9
- SHA1:47f50537ae094c725a60e90bf5e72d563a73abb2 [weak]
- MD5Sum:05500c05300ff2f3be66040cd9d4c24b [weak]
Hashes of received file:
- SHA256:fc9c8ae3385f3b2cdb7c52c8e4ee5fa5074c843155b7ce4786b3ce3c97fe8c3f
- SHA1:59b7721865c7a9c1b313ce11f11aefa4c7951fd4 [weak]
- MD5Sum:05500c05300ff2f3be66040cd9d4c24b [weak]
- Filesize:1291458 [weak]
Last modification reported: Mon, 28 Sep 2020 16:55:59 +0000
Release file created at: Tue, 29 Sep 2020 10:33:40 +0000
E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/main/i18n/by-hash/SHA256/66c9979e0ab12165a3ab86f426e3e910d52933bce60ab14fa80a596e1733b0b3
E: Some index files failed to download. They have been ignored, or old ones used instead.
我已经尝试了一些我在网上找到的解决方案,但都没有奏效。
解决方案 1:
sudo rm -rf /var/lib/apt/lists/*
sudo apt-get update -o Acquire::CompressionTypes::Order::=gz
sudo apt-get update && sudo apt-get upgrade
解决方案 2
sudo rm -rvf /var/lib/apt/lists/*
echo "APT::Cache-Limit "100000000";" >> /etc/apt/apt.conf.d/70debconf
解决方案 3
sudo rm -rvf /var/lib/apt/lists/*
&& sudo mv /var/lib/dpkg/status /var/lib/dpkg/status-bad
&& sudo cp /var/lib/dpkg/status-old /var/lib/dpkg/status
&& sudo apt-get update
解决方案 4
sudo apt-get autoclean && sudo apt-get autoremove -y && sudo apt-get update
解决方案 5
sudo rm -rf /var/lib/apt/lists
sudo apt-get clean
sudo apt-get update
我也尝试添加 Ubuntu 密钥服务器:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 16126D3A3E5C1192
这是我的 source.list
deb http://archive.ubuntu.com/ubuntu focal-updates main restricted
deb http://archive.ubuntu.com/ubuntu focal universe
deb http://archive.ubuntu.com/ubuntu focal-updates universe
deb http://archive.ubuntu.com/ubuntu focal multiverse
deb http://archive.ubuntu.com/ubuntu focal-updates multiverse
deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse
我将不胜感激任何建议! 谢谢
ps:在我的 WSL2 上一切正常。
【问题讨论】:
【参考方案1】:在我遇到同样问题的情况下,以下解决方案有效:
sudo su -
mkdir /etc/gcrypt
echo all >> /etc/gcrypt/hwf.deny
apt-get update
我的环境 Windows 10.0.19041.508 流浪者 2.2.10 VirtualBox 6.1.14r140239ubuntu/focal64 Vagrant Box
我在这里找到了答案和解释:askubuntu.com/questions/1235914/hash-sum-mismatch-error-due-to-identical-sha1-and-md5-but-different-sha256
我尝试在 VM 中安装 Docker (get-docker.sh) 并得到非常相似的错误:“Failed to fetch https://download.docker.com ... Hash Sum mismatch”。所以我认为这类问题与VM无关,而是与Windows 10主机有关。
我将 Hyper-V 启动类型更改为 off
并重新启动系统:
bcdedit /set hypervisorlaunchtype off
我不太明白为什么,但这两个问题都消失了。
【讨论】:
这对我有用(Windows 10 主机上的 VirtualBox,Xubuntu vdi)。它修复了apt
和在更新缓存时无论我选择哪个镜像都会冻结的软件商店。
完美答案,尝试了所有 OP 所做的,这是唯一有效的。
在 Ubuntu 20.04 中工作:)。【参考方案2】:
这对我有用:
我去了系统更新程序并将update from local server
更改为update from main server
,然后我运行sudo apt update
并且它工作了。我希望它也适合你
【讨论】:
这对我有用,但在服务器上,您需要将/etc/apt/sources.list
网址从 http://region.archive.ubuntu.com/ubuntu
更改为 http://archive.ubuntu.com/ubuntu
@sdykae 谢谢你。解决了我的问题。 Ubuntu 20.04,Thinkpad X1 Extreme Gen 2,janky 安装脚本搞砸了我的来源。我相信列表。以上是关于apt-get 使用 Multipass 更新 Ubuntu 20.04 VM 时的哈希和不匹配的主要内容,如果未能解决你的问题,请参考以下文章
Multipass中文文档-使用Packer打包Multipass镜像
Multipass中文文档-使用Packer打包Multipass镜像