无论使用哪个镜像作为主组件,ubuntu 更新和升级都会失败,并出现以下错误。这会阻止系统更新和安装新软件包。
更新日志
Ign:14 http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu jammy amd64 Contents (deb)
Ign:14 http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu jammy amd64 Contents (deb)
Err:14 http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu jammy amd64 Contents (deb)
Connection failed [IP: 43.240.66.200 80]
Fetched 252 MB in 3min 44s (1,127 kB/s)
Reading package lists... Done
E: Failed to fetch http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu/dists/jammy/Contents-amd64 Connection failed [IP: 43.240.66.200 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
升级日志
Ign:21 http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu jammy amd64 Contents (deb)
Err:21 http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu jammy amd64 Contents (deb)
Connection failed [IP: 43.240.66.200 80]
Fetched 249 MB in 2min 1s (2,054 kB/s)
Reading package lists... Done
E: Failed to fetch http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu/dists/jammy/Contents-amd64 Connection failed [IP: 43.240.66.200 80]
E: Failed to fetch https://ubuntu-ports.mirror.net.in/dists/jammy/main/binary-i386/Packages 404 Not Found [IP: 103.195.68.3 443]
E: Failed to fetch https://ubuntu-ports.mirror.net.in/dists/jammy-updates/main/binary-i386/Packages 404 Not Found [IP: 103.195.68.3 443]
E: Failed to fetch https://ubuntu-ports.mirror.net.in/dists/jammy-backports/main/binary-i386/Packages 404 Not Found [IP: 103.195.68.3 443]
E: Failed to fetch https://ubuntu-ports.mirror.net.in/dists/jammy-security/main/binary-amd64/Packages 404 Not Found [IP: 103.195.68.3 443]
E: Some index files failed to download. They have been ignored, or old ones used instead.
bhargav@bhargav-Lenovo-Legion-Y540-15IRH-PG0:~$
起初,我以为是我的 ISP 阻止了 URL,但同一网络内的另一台机器运行正常。
镜子尝试至今,
http://archive.ubuntu.com/ubuntu
https://ubuntu-ports.mirror.net.in
https://mirror.renu.ac.ug/ubuntu
http://in.archive.ubuntu.com/ubuntu
http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu
以下是日志archive.ubuntu.com
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:4 http://archive.ubuntu.com/ubuntu jammy-security InRelease
Hit:5 https://apt.kitware.com/ubuntu focal InRelease
Get:6 http://archive.ubuntu.com/ubuntu jammy amd64 Contents (deb) [46.9 MB]
Ign:6 http://archive.ubuntu.com/ubuntu jammy amd64 Contents (deb)
Get:7 http://archive.ubuntu.com/ubuntu jammy i386 Contents (deb) [36.9 MB]
Get:8 http://archive.ubuntu.com/ubuntu jammy/main amd64 c-n-f Metadata [30.3 kB]
Get:9 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages [129 kB]
Get:10 http://archive.ubuntu.com/ubuntu jammy/restricted i386 Packages [30.4 kB]
Get:11 http://archive.ubuntu.com/ubuntu jammy/restricted Translation-en [18.6 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 c-n-f Metadata [488 B]
Get:13 http://archive.ubuntu.com/ubuntu jammy/universe i386 Packages [7,474 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [14.1 MB]
Get:15 http://archive.ubuntu.com/ubuntu jammy/universe Translation-en [5,652 kB]
Get:16 http://archive.ubuntu.com/ubuntu jammy/universe amd64 DEP-11 Metadata [3,559 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy/universe DEP-11 48x48 Icons [3,447 kB]
Ign:17 http://archive.ubuntu.com/ubuntu jammy/universe DEP-11 48x48 Icons
Get:18 http://archive.ubuntu.com/ubuntu jammy/universe DEP-11 64x64 Icons [7,609 kB]
Get:18 http://archive.ubuntu.com/ubuntu jammy/universe DEP-11 64x64 Icons [7,609 kB]
Get:19 http://archive.ubuntu.com/ubuntu jammy/universe DEP-11 64x64@2 Icons [69.3 kB]
Get:20 http://archive.ubuntu.com/ubuntu jammy/universe amd64 c-n-f Metadata [286 kB]
Get:21 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [217 kB]
Get:22 http://archive.ubuntu.com/ubuntu jammy/multiverse i386 Packages [112 kB]
Get:23 http://archive.ubuntu.com/ubuntu jammy/multiverse Translation-en [112 kB]
Get:24 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 DEP-11 Metadata [42.1 kB]
Get:25 http://archive.ubuntu.com/ubuntu jammy/multiverse DEP-11 48x48 Icons [42.7 kB]
Get:26 http://archive.ubuntu.com/ubuntu jammy/multiverse DEP-11 64x64 Icons [193 kB]
Get:27 http://archive.ubuntu.com/ubuntu jammy/multiverse DEP-11 64x64@2 Icons [214 B]
Get:28 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 c-n-f Metadata [8,372 B]
Ign:6 http://archive.ubuntu.com/ubuntu jammy amd64 Contents (deb)
Get:17 http://archive.ubuntu.com/ubuntu jammy/universe DEP-11 48x48 Icons [3,447 kB]
Ign:17 http://archive.ubuntu.com/ubuntu jammy/universe DEP-11 48x48 Icons
Ign:6 http://archive.ubuntu.com/ubuntu jammy amd64 Contents (deb)
Ign:17 http://archive.ubuntu.com/ubuntu jammy/universe DEP-11 48x48 Icons
Err:6 http://archive.ubuntu.com/ubuntu jammy amd64 Contents (deb)
Connection failed [IP: 91.189.91.38 80]
Ign:17 http://archive.ubuntu.com/ubuntu jammy/universe DEP-11 48x48 Icons
Fetched 73.3 MB in 5min 53s (208 kB/s)
Reading package lists... Done
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/Contents-amd64 Connection failed [IP: 91.189.91.38 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
答案1
在深入研究了为什么 apt 不起作用(摆弄名称服务器、代理和 DNS)之后,尽管这些 URL 和 IP 是可以访问的,但我发现我的 ISP 在网速降低时就放弃了这些资源。最后找到了这个页面,其中的方法 2 有效https://docs.e2enetworks.com/guides/apt_slow.html。
以下是我为解决该问题所采取的措施。
- 下载了 netselect(此包在 ubuntu 池中不存在,我也无法通过 apt 安装任何东西)
wget http://ftp.au.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_amd64.deb
- 安装
sudo dpkg -i netselect_0.3.ds1-28+b1_amd64.deb
- 使用以下方式搜索我附近最快的镜像:
sudo netselect -s 20 -t 40 $(wget -qO - http://mirrors.ubuntu.com/mirrors.txt)
26 http://ftp.iitm.ac.in/ubuntu/
37 http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu/
68 https://in.mirror.coganng.com/ubuntu-ports/
97 http://repos.del.extreme-ix.org/ubuntu/
99 http://ubuntu.hbcse.tifr.res.in/ubuntu/
564 http://archive.ubuntu.com/ubuntu/
578 http://archive.ubuntu.com/ubuntu/
1080 http://archive.ubuntu.com/ubuntu/
1696 http://archive.ubuntu.com/ubuntu/
Only found 9 hosts out of 20 requested.
- 替换
http://archive.ubuntu.com/ubuntu
为http://ftp.iitm.ac.in/ubuntu/
/etc/apt/sources.list
现在一切又开始正常工作了:)