据我了解,apt 在内部配置为仅保留当前内核加上另外两个内核(基于此答案)。
但是,我可以在我的系统上看到安装了四个内核:
$ dpkg -l | grep linux-image-.*-generic | grep ^ii
ii linux-image-5.15.0-82-generic 5.15.0-82.91 amd64 Signed kernel image generic
ii linux-image-5.19.0-50-generic 5.19.0-50.50 amd64 Signed kernel image generic
ii linux-image-6.2.0-26-generic 6.2.0-26.26~22.04.1 amd64 Signed kernel image generic
ii linux-image-6.2.0-31-generic 6.2.0-31.31~22.04.1 amd64 Signed kernel image generic
我认为发生这种情况的唯一原因是我最近升级了内核并且尚未重新启动,但情况似乎并非如此:
$ uname -a
Linux hostname 6.2.0-31-generic #31~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Aug 16 13:45:26 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
运行sudo apt autoremove
不会卸载任何其他内核:
$ sudo apt autoremove --purge
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
...
如果我列出所有 linux-image 包,这就是我得到的:
$ dpkg -l | grep linux-image | grep ^ii
ii linux-image-5.15.0-82-generic 5.15.0-82.91 amd64 Signed kernel image generic
ii linux-image-5.19.0-50-generic 5.19.0-50.50 amd64 Signed kernel image generic
ii linux-image-6.2.0-26-generic 6.2.0-26.26~22.04.1 amd64 Signed kernel image generic
ii linux-image-6.2.0-31-generic 6.2.0-31.31~22.04.1 amd64 Signed kernel image generic
ii linux-image-generic 5.15.0.82.78 amd64 Generic Linux kernel image
ii linux-image-generic-hwe-22.04 6.2.0.31.31~22.04.8 amd64 Generic Linux kernel image
linux-image-generic-hwe-22.04
需要 6.2.0-31 内核,所以我猜测 apt 会保留该内核以及之前的两个内核。
并且linux-image-generic
似乎还需要 5.15.0-82 内核,所以我想这解释了为什么要保留第四个内核?
但删除后linux-image-generic
,sudo apt autoremove
仍然没有删除第四个内核。