旧内核文件正在堆积如山,我想删除除当前版本和之前两个版本之外的所有文件以清除一些空间。
当我运行时apt autoremove
,旧内核不被识别为可以删除。
所以我看了一下/etc/apt/apt.conf.d/01autoremove
,似乎所有linux-image
包裹都包含在内NeverAutoRemove
,这解释了为什么它们没有被领取apt autoremove
。内容如下:
APT
{
NeverAutoRemove
{
"^firmware-linux.*";
"^linux-firmware$";
"^linux-image-[a-z0-9]*$";
"^linux-image-[a-z0-9]*-[a-z0-9]*$";
};
VersionedKernelPackages
{
# kernels
"linux-.*";
"kfreebsd-.*";
"gnumach-.*";
# (out-of-tree) modules
".*-modules";
".*-kernel";
};
Never-MarkAuto-Sections
{
"metapackages";
"contrib/metapackages";
"non-free/metapackages";
"restricted/metapackages";
"universe/metapackages";
"multiverse/metapackages";
};
Move-Autobit-Sections
{
"oldlibs";
"contrib/oldlibs";
"non-free/oldlibs";
"restricted/oldlibs";
"universe/oldlibs";
"multiverse/oldlibs";
};
};
我还看到所有图像,标题和模块(使用带有linux-surface内核的 Pop!_OS)都标记为手动安装apt-mark showmanual | grep linux
:
linux-headers-6.0.12-76060006
linux-headers-6.0.12-76060006-generic
linux-headers-6.0.6-76060006
linux-headers-6.1.11-76060111
linux-headers-6.1.11-76060111-generic
linux-headers-6.1.11-surface
linux-headers-6.1.12-surface
linux-headers-6.1.6-surface
linux-headers-6.2.0-76060200
linux-headers-6.2.0-76060200-generic
linux-headers-6.2.10-surface
linux-headers-6.2.14-surface
linux-headers-6.2.2-surface
linux-headers-6.2.5-surface
linux-headers-6.2.6-76060206
linux-headers-6.2.6-76060206-generic
linux-headers-6.2.8-surface
linux-headers-6.3.3-surface
linux-headers-6.3.7-surface
linux-headers-6.4.12-surface
linux-headers-6.4.2-surface
linux-headers-6.4.4-surface
linux-headers-6.4.6-76060406
linux-headers-6.4.6-76060406-generic
linux-headers-6.5.4-76060504
linux-headers-6.5.4-76060504-generic
linux-headers-6.5.5-surface
linux-headers-6.5.6-76060506
linux-headers-6.5.6-76060506-generic
linux-headers-6.5.6-surface
linux-headers-6.5.7-surface-2
linux-headers-6.6.1-surface-1
linux-headers-6.6.10-76060610
linux-headers-6.6.10-76060610-generic
linux-headers-6.6.11-surface-1
linux-headers-6.6.5-surface-1
linux-headers-6.6.6-76060606
linux-headers-6.6.6-76060606-generic
linux-headers-6.6.6-surface-1
linux-headers-6.7.2-surface-1
linux-headers-6.7.6-surface-1
linux-headers-6.7.9-surface-1
linux-headers-6.8.0-76060800daily20240311
linux-headers-6.8.0-76060800daily20240311-generic
linux-headers-6.8.1-surface-1
linux-headers-6.8.8-surface-1
linux-headers-6.9.3-76060903
linux-headers-6.9.3-76060903-generic
linux-headers-6.9.3-surface-2
linux-headers-surface
linux-image-6.1.11-surface
linux-image-6.1.12-surface
linux-image-6.1.6-surface
linux-image-6.2.0-76060200-generic
linux-image-6.2.10-surface
linux-image-6.2.14-surface
linux-image-6.2.2-surface
linux-image-6.2.5-surface
linux-image-6.2.6-76060206-generic
linux-image-6.2.8-surface
linux-image-6.3.3-surface
linux-image-6.3.7-surface
linux-image-6.4.12-surface
linux-image-6.4.2-surface
linux-image-6.4.4-surface
linux-image-6.4.6-76060406-generic
linux-image-6.5.4-76060504-generic
linux-image-6.5.5-surface
linux-image-6.5.6-76060506-generic
linux-image-6.5.6-surface
linux-image-6.5.7-surface-2
linux-image-6.6.1-surface-1
linux-image-6.6.10-76060610-generic
linux-image-6.6.11-surface-1
linux-image-6.6.5-surface-1
linux-image-6.6.6-76060606-generic
linux-image-6.6.6-surface-1
linux-image-6.7.2-surface-1
linux-image-6.7.6-surface-1
linux-image-6.7.9-surface-1
linux-image-6.8.0-76060800daily20240311-generic
linux-image-6.8.1-surface-1
linux-image-6.8.8-surface-1
linux-image-6.9.3-76060903-generic
linux-image-6.9.3-surface-2
linux-image-surface
linux-modules-6.0.12-76060006-generic
linux-modules-6.1.11-76060111-generic
linux-modules-6.2.0-76060200-generic
linux-modules-6.2.6-76060206-generic
linux-modules-6.4.6-76060406-generic
linux-modules-6.5.4-76060504-generic
linux-modules-6.5.6-76060506-generic
linux-modules-6.6.10-76060610-generic
linux-modules-6.6.6-76060606-generic
linux-modules-6.8.0-76060800daily20240311-generic
linux-modules-6.9.3-76060903-generic
因此我尝试使用以下命令手动删除一个最旧的软件包apt remove linux-image-6.1.11-76060111-generic
:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
linux-image-6.1.11-76060111-generic
0 upgraded, 0 newly installed, 1 to remove and 250 not upgraded.
After this operation, 12.3 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 1219145 files and directories currently installed.)
Removing linux-image-6.1.11-76060111-generic (6.1.11-76060111.202302091138~1675975749~22.04~f771a7f) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-6.1.11-76060111-generic
不过,这留下了标头和模块包。我看到它们列VersionedKernelPackages
在自动移除配置下,但我的理解是自动移除应该默认只保留最后几个版本。
检查剩余标题和模块的依赖关系仅显示对成功删除的linux-image
包的依赖:
user@os:~$ apt-cache rdepends linux-headers-6.1.11-76060111-generic
linux-headers-6.1.11-76060111-generic
Reverse Depends:
linux-image-6.1.11-76060111-generic
user@os:~$ apt-cache rdepends linux-modules-6.1.11-76060111-generic
linux-modules-6.1.11-76060111-generic
Reverse Depends:
linux-image-6.1.11-76060111-generic
还有哪些因素可能导致这些包裹无法随linux-image
包裹一起被移除?
您的内核包无法自动删除,因为它们被标记为手动安装。整个“保持正在运行和自动删除最后两个内核”设置依赖于通过元包(如
linux-image-surface
和)自动安装的内核包linux-headers-surface
;如果它们最终被标记为手动安装,则无法正常工作。我不知道您的系统为何会出现这种情况。要清理它,您最好手动进行: