0

I am on Ubuntu 20.04 and I trying to understand what's going on with my Linux kernels, and there is something that looks odd to me. The current kernel should be:

@precision-3551:~$ uname -r
5.13.0-44-generic

But I can also see that there are other installed kernels. One curious thing is that the installed kernels are either 5.13 or 5.4, with nothing in between:

@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 

And when I try purge, I don't get any listed ones:

@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.

I have also looked into /etc/apt/apt.conf.d/01autoremove-kernels, as suggested by this answer, but that file does not exist in my case. I think that by removing the 5.4 kernels I can save a bit of space. How can I do that or is there any signs I shouldn't?

Py-ser
  • 697
  • If you have both GA & HWE kernels installed; currently a 20.04 system will contain both 5.4 (GA) & 5.13 (HWE) installed. Have you checked you don't have kernel stacks installed? – guiverc May 26 '22 at 07:19
  • I am not sure what all this means. And In any case, I should be able to remove at least some of the 5.4 kernels, correct? How do I check for what you said? I am reading at this but can't really follow it. – Py-ser May 26 '22 at 07:36

2 Answers2

1

Let's take a minute and simply reorganize that list. Maybe it will make more sense now:

// OEM Kernel packages
ii  linux-image-oem-osp1                       5.4.0.113.117                       amd64        Depends on the generic kernel image (dummy transitional package)
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
rc  linux-image-5.0.0-1034-oem-osp1            5.0.0-1034.39                       amd64        Signed kernel image oem-osp1

// Original 20.04 kernel 5.4 packages ii linux-image-generic 5.4.0.113.117 amd64 Generic Linux kernel image ii linux-image-5.4.0-113-generic 5.4.0-113.127 amd64 Signed kernel image generic ii linux-headers-generic 5.4.0.113.117 amd64 Generic Linux kernel headers 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

// Hardware Enablement (HWE) 20.04 kernel 5.13 packages ii linux-image-generic-hwe-20.04 5.13.0.44.49~20.04.28 amd64 Generic Linux kernel image 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-headers-generic-hwe-20.04 5.13.0.44.49~20.04.28 amd64 Generic Linux kernel headers 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

  • rc kernels are not installed, and take no space. Those are simply entries in the apt database of kernels that apt knew about in the past. We ignore most of them.

  • You have an OEM kernel metapackage and headers. OEM kernels are intended for specific hardware for a limited time, until hardware support for that hardware finds its way into the mainline kernel. If your hardware works fine on your current 5.13 kernel, then you don't need those 5.0 and 5.4 OEM kernel packages anymore. Simply apt remove them: sudo apt remove linux-image-oem-osp1 linux-headers-5.0.0-1034-oem-osp1. See? That was easy.

  • You have the original 5.4 kernel stack that came with Ubuntu 20.04. But you are not using it (you are using the HWE 5.13 series). Unless you plan to revert to 5.4, you can simply apt remove those five packages.

  • You have two versions of your current 5.13 kernel, -44 and the older -41. That's what correct looks like (you should indeed have two). DON'T remove any of those packages. Let apt handle this series automatically.

  • Looks like there is nothing wrong with apt. It is indeed automatically deleting older kernels -- that's why you have so many rc kernels listed. You have so many installed kernels because you --the human admin-- did not instruct apt to uninstall those OEM and 5.4 metapackages, and pulling in additional kernels is what those metapackages do!

user535733
  • 62,253
0

You kernel with state "rc" are uninstalled already, but some configuration might be still there. If you want to clean the configuration, you can do sudo dpkg --purge <name of package>, by example sudo dpkg --purge linux-image-5.4.0-86-generic.

ob2
  • 3,553