Remove linux image generic

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

If you think one of the answers are correct please click on the gray check mark 🗸 next to the answer and turn it green ✅. This will mark your problem as solved and help others find the right answer.

2 Answers 2

Don’t delete these files!

It looks like you have two kernels:

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.

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.

Источник

How to Delete Old Unused Kernels in Debian and Ubuntu

In our last article, we’ve explained how to delete old unused kernels in CentOS/RHEL/Fedora. In this article, we will explain how to delete old unused kernels in Debian and Ubuntu systems, but before moving further, you may want to install the latest version in order to take advantage of: security fixes, new kernel functions, updated drivers and so much more.

Читайте также:  Linux процесс слушающий порт

To upgrade your kernel to latest version in Ubuntu and Debian, follow this guide:

Important: It is advisable to keep at least one or two old kernels to fall back to in case there is a problem with an update.

To find out the current version of Linux kernel running on your system, use the following command.

$ uname -sr Linux 4.12.0-041200-generic 

To list all installed kernels on your system, issue this command.

$ dpkg -l | grep linux-image | awk '' linux-image-4.12.0-041200-generic linux-image-4.8.0-22-generic linux-image-extra-4.8.0-22-generic linux-image-generic 

Remove Old Unused Kernels on Debian and Ubuntu

Run the commands below to remove a particular linux-image along with its configuration files, then update grub2 configuration, and lastly reboot the system.

$ sudo apt remove --purge linux-image-4.4.0-21-generic $ sudo update-grub2 $ sudo reboot
[sudo] password for tecmint: Reading package lists. Done Building dependency tree Reading state information. Done The following additional packages will be installed: linux-generic linux-headers-4.8.0-59 linux-headers-4.8.0-59-generic linux-headers-generic linux-image-4.8.0-59-generic linux-image-extra-4.8.0-59-generic linux-image-generic Suggested packages: fdutils linux-doc-4.8.0 | linux-source-4.8.0 linux-tools Recommended packages: thermald The following packages will be REMOVED: linux-image-4.8.0-22-generic* linux-image-extra-4.8.0-22-generic* The following NEW packages will be installed: linux-headers-4.8.0-59 linux-headers-4.8.0-59-generic linux-image-4.8.0-59-generic linux-image-extra-4.8.0-59-generic The following packages will be upgraded: linux-generic linux-headers-generic linux-image-generic 3 upgraded, 4 newly installed, 2 to remove and 182 not upgraded. Need to get 72.0 MB of archives. After this operation, 81.7 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-headers-4.8.0-59 all 4.8.0-59.64 [10.2 MB] Get:2 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-headers-4.8.0-59-generic amd64 4.8.0-59.64 [811 kB] Get:3 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-generic amd64 4.8.0.59.72 [1,782 B] Get:4 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-headers-generic amd64 4.8.0.59.72 [2,320 B] Get:5 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-image-4.8.0-59-generic amd64 4.8.0-59.64 [23.6 MB] Get:6 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-image-extra-4.8.0-59-generic amd64 4.8.0-59.64 [37.4 MB] Get:7 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 linux-image-generic amd64 4.8.0.59.72 [2,348 B] Fetched 72.0 MB in 7min 12s (167 kB/s) Selecting previously unselected package linux-headers-4.8.0-59. (Reading database . 104895 files and directories currently installed.) Preparing to unpack . /0-linux-headers-4.8.0-59_4.8.0-59.64_all.deb . Unpacking linux-headers-4.8.0-59 (4.8.0-59.64) . Selecting previously unselected package linux-headers-4.8.0-59-generic. Preparing to unpack . /1-linux-headers-4.8.0-59-generic_4.8.0-59.64_amd64.deb . Unpacking linux-headers-4.8.0-59-generic (4.8.0-59.64) . Preparing to unpack . /2-linux-generic_4.8.0.59.72_amd64.deb . Unpacking linux-generic (4.8.0.59.72) over (4.8.0.22.31) . Preparing to unpack . /3-linux-headers-generic_4.8.0.59.72_amd64.deb . Unpacking linux-headers-generic (4.8.0.59.72) over (4.8.0.22.31) . Selecting previously unselected package linux-image-4.8.0-59-generic. Preparing to unpack . /4-linux-image-4.8.0-59-generic_4.8.0-59.64_amd64.deb . Done. Removing linux-image-4.8.0-22-generic (4.8.0-22.24) . Examining /etc/kernel/postrm.d . run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.8.0-22-generic /boot/vmlinuz-4.8.0-22-generic update-initramfs: Deleting /boot/initrd.img-4.8.0-22-generic run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.8.0-22-generic /boot/vmlinuz-4.8.0-22-generic Generating grub configuration file . Found linux image: /boot/vmlinuz-4.12.0-041200-generic Found initrd image: /boot/initrd.img-4.12.0-041200-generic Found linux image: /boot/vmlinuz-4.8.0-59-generic done .

Although this method works just fine, it is more reliable and efficient to use a handy script called “byobu” that combines all the commands above into a single program with useful options such as specifying number of kernels to keep on the system.

Читайте также:  Hd 2400 pro linux

Install byobu script package which provides a program called purge-old-kernels used for removing old kernels and header packages from the system.

Then remove old kernels like so (the command below allows 2 kernels to be kept on the system).

$ sudo purge-old-kernels --keep 2

You may also like to read these following related articles on Linux kernel.

In this article, we have described how to remove old unused kernel images on Ubuntu and Debian systems. You can share any thoughts via the feedback from below.

Источник

How to delete a non-working kernel after update?

I have. a simple question. After I updated my kernel, I couldn’t boot (stuck on purple screen) unless I chose the old kernel. So how do I delete the new kernel with synaptic. And how do I do this safely? I’m in Quantal Quetzel. My kernel is 3.5.0-40. The working kernel is 3.5.0-39. Also, how do I stop kernel updates from appearing in the update manager? Thanks.

If you’d prefer answers to include information about preventing the new kernel from being installed again with your other updates, you might want to include that in your question.

I think it is not wise to delete the kernel or to stop kernel updates, as they are usually security updates. See this question about a better practice.

5 Answers 5

If the latest kernel update break things (Original question), the best option for most is to fall back to the previous working kernel (provided that you keep at least 1 fallback option).

Otherwise, use @ZAB ‘s solution to install a specific version of the kernel version provided via the apt package manager.

In generic, to remove the unwanted out-dated kernels, open a terminal session and run the command:

IMPORTANT: If /boot is NOT on its tiny partition (running out of space), avoid explicitly purging old kernels. Consider them backup / fallback options when upgrade introduces problems (hardware driver modules, etc.).

Good read on kernel upgrade and preservation mechanism: How does apt on Ubuntu decide how many old kernels to keep

TL;DR: Take a look at /etc/apt/apt.conf.d/01autoremove-kernels file generated by postinstall hook (script).

Snippet from Ubuntu 20.04 LTS running 5.4.0 for a better understanding:

// DO NOT EDIT! File autogenerated by /etc/kernel/postinst.d/apt-auto-removal APT::NeverAutoRemove < "^linux-.*-5\.4\.0-28-generic$"; "^linux-.*-5\.4\.0-29-generic$"; "^linux-.*-5\.4\.0-31-generic$"; "^kfreebsd-.*-5\.4\.0-28-generic$"; "^kfreebsd-.*-5\.4\.0-29-generic$"; "^kfreebsd-.*-5\.4\.0-31-generic$"; "^gnumach-.*-5\.4\.0-28-generic$"; "^gnumach-.*-5\.4\.0-29-generic$"; "^gnumach-.*-5\.4\.0-31-generic$"; "^.*-modules-5\.4\.0-28-generic$"; "^.*-modules-5\.4\.0-29-generic$"; "^.*-modules-5\.4\.0-31-generic$"; "^.*-kernel-5\.4\.0-28-generic$"; "^.*-kernel-5\.4\.0-29-generic$"; "^.*-kernel-5\.4\.0-31-generic$"; >; 

Find the kernel package name

At the time of writing, on amd64/x86_64 architecture the image name was: linux-image-$(uname -r)-generic

For unsigned kernel images, like those created by nvidia drivers, the image could be: linux-image-unsigned-4.20.17-042017-generic

Читайте также:  Linux проверить какая видеокарта используется

Remove (purge — remove all configuration files as well)

sudo apt-get purge linux-image-3.5.0-40-generic 

If you want to do a deep clean (leftover package configs. ), USE WITH CAUTION:

dpkg -l | awk '/^rc/ < print $2 >' | xargs apt-get purge -y dpkg -l | awk '/^rc/ < print $2 >' | xargs dpkg -P 

NOTE: For Ubuntu 18.04 LTS or later, you may also want to remove any linux-modules or linux-headers packages of the same version to save disk spaces / keep you system lean.

Update — 2020-05-21

Explicitly purging old kernels may cause unexpected results. Not recommended unless /boot is on its own tiny partition (out of space).

Refer to @ZAB ‘s approach to get rid of the latest kernel update which introduces bug (break things).

There is no (I personally haven’t found) easy equivalent to Fedora/RHEL/CentOS approach by setting installonly_limit=2 to tell DNF or YUM to only keep latest 2 kernels.

sudo apt-get update && apt-get dist-upgrade -y , not sure if you have linux-current-generic or linux-image-generic-lts-raring on non-LTS releases.

This malicious solution will also remove the dependent package linux-image-generic-* . The system will stop getting kernel updates and older kernels will be removed by consequent autoremove call which will break you system completely.

Don’t blindly do what was suggested in the accepted answer. It will break your system. Read what apt utility tells you before pressing y .

The following steps was done to remove the buggy kernel 5.3.0-53 for example. The previous working kernel was 5.3.0-51 .

First run sudo apt remove linux-image-5.3.0-53-generic —verbose-versions and read the output:

. The following NEW packages will be installed: linux-image-unsigned-5.3.0-53-generic (5.3.0.53.109) . 

We don’t need this package, press n and ask to remove it as well sudo remove linux-image-5.3.0-53-generic linux-image-unsigned-5.3.0-53-generic —verbose-versions now prints this:

. The following packages will be REMOVED: linux-generic-hwe-18.04 (5.3.0.53.109) . 

This package is important, this is the main distributive package that provides us with kernel updates. We need to reinstall the previous version of it. So press y and find the previous good kernel version. In my case it is 5.3.0.51.104 . Try to reinstall it sudo apt install linux-generic-hwe-18.04=5.3.0.51.104 —verbose-versions , prints this:

The following packages have unmet dependencies: linux-generic-hwe-18.04 : Depends: linux-image-generic-hwe-18.04 (= 5.3.0.51.104) but 5.3.0.53.109 is to be installed Depends: linux-headers-generic-hwe-18.04 (= 5.3.0.51.104) but 5.3.0.53.109 is to be installed 

Let blacklist this newer version we don’t like. Edit file /etc/apt/preferences and add this:

Package: linux-generic-hwe-18.04 linux-image-generic-hwe-18.04 linux-headers-generic-hwe-18.04 Pin: version 5.3.0.53.109 Pin-Priority: -1 

Repeat sudo apt install linux-generic-hwe-18.04=5.3.0.51.104 —verbose-versions check the output, in my case everything seems fine, so I agree and reboot.

Источник

Оцените статью
Adblock
detector