Can I delete linux-image-generic-hwe-20.04?

i have the following kernels :

linux-image-5.11.0-27-generic
linux-image-5.11.0-38-generic
linux-image-generic-hwe-20.04

I would like to delete these 2 kernels

linux-image-5.11.0-27-generic  
linux-image-generic-hwe-20.04
  1. Is it safe to do so?
  2. I tried using sudo apt autoremove --purge to delete old kernels but the old kernels still show up?

Solution 1:

Don't delete these files!

It looks like you have two kernels:

  • The current one ending with -38,
  • And one before that ending with -27.

This is normal for Ubuntu. One older kernel (-27) is there for your protection. If for any reason the current kernel breaks you will be able to boot using the older one.

The linux-image-generic-hwe-20.04 is not a kernel. It is "meta package" that tells Ubuntu which kernels to keep up to date. If you delete it, you will not get any kernel security updates.

In other words, don't mess with kernel files. always use sudo apt autoremove. It will always keep the last two kernels.

Hope this helps

Solution 2:

The package linux-image-generic-hwe-20.04 is not as such a kernel. It is the metapackage that brings in the newest kernel image for the kernels from the HWE stack.

Ubuntu 20.04 is a long term release. In principle, it remains on the same long term supported kernel release for the entire support time. However, later in the release cycle, i.e., starting with the .2 version (20.04.2), updated installation media are shipped with updated kernels, the so called Hardware Enablement (HWE) stack. This allows the long term release to continue working properly with newer hardware.

The package linux-image-generic-hwe-20.04 in turn depends on linux-generic-hwe-20.04. That is the top level metapackage that ensures that the HWE kernel (image and headers) are automatically updated to the latest available version. For the regular kernel series, the linux-generic package fulfills that role.

You can delete that package, but if you do, also linux-generic-hwe-20.04 will be removed, and linux-image-generic-hwe-20.04 will be removed with the next autoremove. You will not break your system, but your kernels will not anymore be automatically updated.