为什么在 Ubuntu 18.04 中从“apt update”下载的内容如此之大(160+MB)?

为什么在 Ubuntu 18.04 中从“apt update”下载的内容如此之大(160+MB)?

我遇到了一个非常大的“apt update”下载问题(160+ MB),这种情况时有发生,尤其是在几天不更新和检查的时候。几个小时后再运行一次更新可能不会导致这么大的下载,而只有 7MB 左右。在关于这个问题的旧帖子中注意到,

据说该问题已得到解决,但这次又出现了,我怀疑原因可能与多年前略有不同。

我必须补充一点,我已通过设置标志来禁用自动更新

/etc/apt/apt.conf.d/20auto-upgrades

0,但我不知道对系统进行任何其他与更新相关的更改。此外,这种情况并非发生在所有运行该软件的系统上,其中一个系统始终有正常更新,小于 10MB。

以下是完整终端输出的示例:

$ apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [753 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [531 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages [593 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [295 kB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/main i386 Packages [382 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [73.8 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [143 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu bionic-updates i386 Contents (deb) [33.0 MB]
Get:13 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [38.5 kB]
Get:14 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 48x48 Icons [17.6 kB]
Get:15 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons [41.5 kB]
Get:16 http://security.ubuntu.com/ubuntu bionic-security amd64 Contents (deb) [43.8 MB]
Get:17 http://us.archive.ubuntu.com/ubuntu bionic-updates amd64 Contents (deb) [50.3 MB]
Get:18 http://security.ubuntu.com/ubuntu bionic-security i386 Contents (deb) [28.3 MB]
Get:19 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages [982 kB]
Get:20 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,012 kB]
Get:21 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [253 kB]
Get:22 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [201 kB]
Get:23 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [437 kB]
Get:24 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:25 http://us.archive.ubuntu.com/ubuntu bionic-backports amd64 Contents (deb) [8,376 B]
Get:26 http://us.archive.ubuntu.com/ubuntu bionic-backports i386 Contents (deb) [8,376 B]
Get:27 http://us.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,920 B]
Get:28 http://security.ubuntu.com/ubuntu bionic-security/universe i386 Packages [593 kB]
Get:29 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [613 kB]
Get:30 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [42.1 kB]
Get:31 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [16.4 kB]
Get:32 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [116 kB]
Get:33 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Fetched 163 MB in 1min 33s (1,742 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
5 packages can be upgraded. Run 'apt list --upgradable' to see them.
$

以下仅列出上述下载报告中的大文件(MB 大小):

Get:12 http://us.archive.ubuntu.com/ubuntu bionic-updates i386 Contents (deb) [33.0 MB]
Get:16 http://security.ubuntu.com/ubuntu bionic-security amd64 Contents (deb) [43.8 MB]
Get:17 http://us.archive.ubuntu.com/ubuntu bionic-updates amd64 Contents (deb) [50.3 MB]
Get:18 http://security.ubuntu.com/ubuntu bionic-security i386 Contents (deb) [28.3 MB]

来源列表如下:

$ cat /etc/apt/sources.list | grep -vE "^#|^$"
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse

最后:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:    18.04
Codename:   bionic

答案1

根据https://salsa.debian.org/apt-team/apt-file,“apt 命令会下载其配置中列出的 Contents 文件。”,这就是 4 个大型“Contents (deb)”文件被如此频繁下载的原因。大约 10 年前,您必须运行“apt-file update”才能重新加载 apt-file 所依赖的数据,现在它已通过系统范围的“apt update”命令自动完成(根据 apt-file 的手册页)。

这解释了为什么在我删除 apt-file 包后,下载大小恢复正常。

答案2

我必须清除该apt-file包而不是仅仅删除它:

sudo apt purge -y apt-file

purge就像是深渊remove。引用man apt-get

purge is identical to remove except that packages are removed and purged (any configuration files are deleted too).

在我的情况下,罪魁祸首是文件/etc/apt/apt.conf.d/50apt-file.conf,而一个简单的remove方法是卸载它


注意:对于那些不了解该apt-file包的人来说,它是一个查询apt数据库的工具(搜索哪个包提供了给定的文件等......)

相关内容