Ubuntu 本地存储库导致“哈希总和不匹配”错误

Ubuntu 本地存储库导致“哈希总和不匹配”错误

我正在使用本地存储库服务器来更新所有 Linux 版本,因为我已经配置了 Ubuntu 20 服务器来更新 Ubuntu 20 服务器,最近开始出现以下错误。尝试删除rm -rf /var/lib/apt从另一个线程找到的文件夹“ ”的内容作为解决方案。

我尝试手动Commands-amd64.xz从本地存储库中删除该文件,因为发现哈希值不匹配,然后运行curl命令再次下载它,这解决了我的问题。但当它按照每日计划再次从 Ubuntu 主存储库同步存储库时,它再次发生。

curl -o Commands-amd64.xz http://archive.ubuntu.com/ubuntu/dists/focal-updates/main/cnf/by-hash/SHA256/68a13b187a08d10f59ed448a305317ca202fd001ac2c62b18f851853c29fc6d5

错误片段:

    Get:48 https://localIPaddress/ubuntu20/mirror/archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 c-n-f Metadata [580 B]
Fetched 23.9 MB in 3s (6,846 kB/s)
Reading package lists... Done
E: Failed to fetch https://<localserverIP>/ubuntu20/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/main/cnf/Commands-amd64.xz  Hash Sum mismatch
   Hashes of expected file:
    - Filesize:14840 [weak]
    - SHA256:68a13b187a08d10f59ed448a305317ca202fd001ac2c62b18f851853c29fc6d5
    - SHA1:dd6e6a72880a22a264a7a40bca6cd9e8ec4dbbbf [weak]
    - MD5Sum:4917444606f7c42d4579abfaddddfbe4 [weak]
   Hashes of received file:
    - SHA256:75d0ec77f608b4ed82a8863208eb909deefe518143a2faa1a38b386541306304
    - SHA1:b9c4e3efbce29c5701b8889872091ab943b92240 [weak]
    - MD5Sum:080f9750feeef30269fed50447a5922a [weak]
    - Filesize:14840 [weak]
   Last modification reported: Mon, 21 Mar 2022 17:17:39 +0000
   Release file created at: Mon, 21 Mar 2022 15:10:25 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.

答案1

我使用 apt-mirror (https://github.com/apt-mirror/apt-mirror) 对于本地 18.04 和 20.04 存储库。我遇到了 Commands-amd64.xz 文件的哈希和不匹配和文件大小不匹配的相同问题。通过在进行镜像同步后立即下载发布文件来解决。我的 postmirror.sh 文件:

#!/bin/bash
cd /var/www/html/ubuntu_repo/mirror
for p in {focal,bionic}{,-{backports,updates}}/{main,restricted,universe,multiverse};do >&2 echo "${p}"
  wget -q -r "http://azure.archive.ubuntu.com/ubuntu/dists/${p}/cnf/Commands-amd64.xz"
  wget -q -r "http://azure.archive.ubuntu.com/ubuntu/dists/${p}/cnf/Commands-i386.xz"
done
for p in {focal-security,bionic-security}/{main,restricted,universe,multiverse};do >&2 echo "${p}"
  wget -q -r "http://security.ubuntu.com/ubuntu/dists/${p}/cnf/Commands-amd64.xz"
  wget -q -r "http://security.ubuntu.com/ubuntu/dists/${p}/cnf/Commands-i386.xz"
done
for p in {focal,bionic}{,-{backports,updates}}/{Release,InRelease,Release.gpg};do >&2 echo "${p}"
  wget -q -r "http://azure.archive.ubuntu.com/ubuntu/dists/${p}"
done
for p in {focal-security,bionic-security}/{Release,InRelease,Release.gpg};do >&2 echo "${p}"
  wget -q -r "http://security.ubuntu.com/ubuntu/dists/${p}"
done

我镜像的存储库适用于 Azure Ubuntu。将它们替换为您使用的存储库。

相关内容