我在 Ubuntu 20.04 上,我试图了解我的 Linux 内核发生了什么,但我觉得有些奇怪。当前内核应该是:
@precision-3551:~$ uname -r
5.13.0-44-generic
但我也可以看到还有其他安装的内核。一件奇怪的事情是,安装的内核要么是 要么5.13
,5.4
两者之间没有任何内容:
@precision-3551:~$ dpkg --list | egrep -i --color 'linux-image|linux-headers'
ii linux-headers-5.0.0-1034-oem-osp1 5.0.0-1034.39 amd64 Linux kernel headers for version 5.0.0 on 64 bit x86 SMP
ii linux-headers-5.13.0-41-generic 5.13.0-41.46~20.04.1 amd64 Linux kernel headers for version 5.13.0 on 64 bit x86 SMP
ii linux-headers-5.13.0-44-generic 5.13.0-44.49~20.04.1 amd64 Linux kernel headers for version 5.13.0 on 64 bit x86 SMP
ii linux-headers-5.4.0-113 5.4.0-113.127 all Header files related to Linux kernel version 5.4.0
ii linux-headers-5.4.0-113-generic 5.4.0-113.127 amd64 Linux kernel headers for version 5.4.0 on 64 bit x86 SMP
ii linux-headers-generic 5.4.0.113.117 amd64 Generic Linux kernel headers
ii linux-headers-generic-hwe-20.04 5.13.0.44.49~20.04.28 amd64 Generic Linux kernel headers
rc linux-image-5.0.0-1034-oem-osp1 5.0.0-1034.39 amd64 Signed kernel image oem-osp1
ii linux-image-5.13.0-41-generic 5.13.0-41.46~20.04.1 amd64 Signed kernel image generic
ii linux-image-5.13.0-44-generic 5.13.0-44.49~20.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-100-generic 5.4.0-100.113 amd64 Signed kernel image generic
rc linux-image-5.4.0-104-generic 5.4.0-104.118 amd64 Signed kernel image generic
rc linux-image-5.4.0-105-generic 5.4.0-105.119 amd64 Signed kernel image generic
rc linux-image-5.4.0-107-generic 5.4.0-107.121 amd64 Signed kernel image generic
rc linux-image-5.4.0-109-generic 5.4.0-109.123 amd64 Signed kernel image generic
rc linux-image-5.4.0-110-generic 5.4.0-110.124 amd64 Signed kernel image generic
ii linux-image-5.4.0-113-generic 5.4.0-113.127 amd64 Signed kernel image generic
rc linux-image-5.4.0-65-generic 5.4.0-65.73~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-66-generic 5.4.0-66.74~18.04.2 amd64 Signed kernel image generic
rc linux-image-5.4.0-70-generic 5.4.0-70.78~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-71-generic 5.4.0-71.79~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-72-generic 5.4.0-72.80~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-73-generic 5.4.0-73.82~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-74-generic 5.4.0-74.83~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-77-generic 5.4.0-77.86~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-80-generic 5.4.0-80.90~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-81-generic 5.4.0-81.91~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-84-generic 5.4.0-84.94~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-86-generic 5.4.0-86.97~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-87-generic 5.4.0-87.98~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-89-generic 5.4.0-89.100~18.04.1 amd64 Signed kernel image generic
rc linux-image-5.4.0-90-generic 5.4.0-90.101 amd64 Signed kernel image generic
rc linux-image-5.4.0-91-generic 5.4.0-91.102 amd64 Signed kernel image generic
rc linux-image-5.4.0-92-generic 5.4.0-92.103 amd64 Signed kernel image generic
rc linux-image-5.4.0-94-generic 5.4.0-94.106 amd64 Signed kernel image generic
rc linux-image-5.4.0-96-generic 5.4.0-96.109 amd64 Signed kernel image generic
rc linux-image-5.4.0-97-generic 5.4.0-97.110 amd64 Signed kernel image generic
rc linux-image-5.4.0-99-generic 5.4.0-99.112 amd64 Signed kernel image generic
ii linux-image-generic 5.4.0.113.117 amd64 Generic Linux kernel image
ii linux-image-generic-hwe-20.04 5.13.0.44.49~20.04.28 amd64 Generic Linux kernel image
ii linux-image-oem-osp1 5.4.0.113.117 amd64 Depends on the generic kernel image (dummy transitional package)
@precision-3551:~$ dpkg --list | grep -i -E --color 'linux-image|linux-kernel' | grep '^ii'
ii linux-image-5.13.0-41-generic 5.13.0-41.46~20.04.1 amd64 Signed kernel image generic
ii linux-image-5.13.0-44-generic 5.13.0-44.49~20.04.1 amd64 Signed kernel image generic
ii linux-image-5.4.0-113-generic 5.4.0-113.127 amd64 Signed kernel image generic
ii linux-image-generic 5.4.0.113.117 amd64 Generic Linux kernel image
ii linux-image-generic-hwe-20.04 5.13.0.44.49~20.04.28 amd64 Generic Linux kernel image
ii linux-image-oem-osp1
当我尝试清除时,我没有得到任何列出的:
@precision-3551:~$ sudo apt --purge autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
正如this answer/etc/apt/apt.conf.d/01autoremove-kernels
所建议的那样,我也调查了,但在我的情况下该文件不存在。我认为通过删除内核可以节省一些空间。我怎么能这样做,或者有任何我不应该这样做的迹象?5.4
让我们花点时间简单地重新组织该列表。也许现在它会更有意义:
rc
内核未安装,不占用空间。这些只是 apt 过去知道的 apt 内核数据库中的条目。我们忽略了他们中的大多数。您有一个 OEM 内核元数据包和标头。OEM 内核在有限的时间内用于特定硬件,直到对该硬件的硬件支持进入主线内核。如果您的硬件在您当前的 5.13 内核上运行良好,那么您不再需要那些 5.0 和 5.4 OEM 内核包。简单地删除它们:
sudo apt remove linux-image-oem-osp1 linux-headers-5.0.0-1034-oem-osp1
. 看?那很简单。您拥有 Ubuntu 20.04 附带的原始 5.4 内核堆栈。但是您没有使用它(您使用的是 HWE 5.13 系列)。除非您打算恢复到 5.4,否则您可以简单地删除这五个包。
您有两个版本的当前 5.13 内核,-44 和较旧的 -41。这就是正确的样子(你确实应该有两个)。不要删除任何这些软件包。让 apt 自动处理这个系列。
看起来apt没有什么问题。它确实会自动删除较旧的内核——这就是为什么
rc
列出这么多内核的原因。你安装了这么多内核是因为你——人类管理员——没有指示 apt 卸载那些 OEM 和 5.4 元包,而引入额外的内核就是这些元包所做的!您的状态为“rc”的内核已经被卸载,但一些配置可能仍然存在。如果你想清理配置,你可以做
sudo dpkg --purge <name of package>
,例如sudo dpkg --purge linux-image-5.4.0-86-generic
。