How to uninstall the latest Linux Kernel and go back to the previous version

When a new version of this kernel is installed, it is usually automatically configured to work optimally on our computer. However, a configuration problem, either internal to our PC or to one of the parts of the kernel, can make everything stop working. And the system may start to experience some behavior problems (with graphics, sound, performance, etc) until it becomes totally unusable.

When bugs are critical, that’s when we usually see the screen of “Kernel Panic«, the equivalent of the blue screen of Windows operating systems.

Fortunately, Linux is prepared to deal with these types of problems. And it’s very rare that we can’t recover from a critical system error related to the latest kernel we just installed.

Linux always saves old kernels

When we download a Linux Kernel update, the system performs some basic configuration tasks to get it up and running. Typically, it compiles and configures it to work with our hardware, and usually launches a bootloader setup (GRUB) so that the next time we boot the system, we load this latest version by default.

But it doesn’t remove old versions of kernels by default, all of them are usually saved on the hard drive. And, in addition, they are registered in GRUB to be able to boot from any of them in case you need to open an old version.

To enter these old versions, what we must do is select the “Advanced Options” entry in the GRUB boot menu, and here we will see all these old versions. In case the boot manager does not appear, because we have configured an automatic boot, we can show it holding down the Shift key while turning on the PC.

In this section we can find at least two different kernels: the last one installed, in normal mode, and the last one in recovery mode. The longer we have had the system installed, the more entries we can find for each of the versions that have been installed.

We simply have to use the keyboard arrows to select the version of the Kernel that we want to boot, and press Enter. Instead of booting the system with the default kernel, it will boot using the chosen version of it.

Change the default boot kernel

When we install a new version of the Linux kernel, it is configured as the main version, to boot by default, and leaves the other versions in second place in the «Advanced Options«. What we cannot do is, every time we turn on the PC, be aware of GRUB to choose the different version. Therefore, if we do not want to use the latest, and we want to use another specific version of the kernel, we will have to change it by hand.

We can use a program called “Grub Customizer”, which we can install with the following commands:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer sudo apt-get update sudo apt-get install grub-customizer

And, once opened, we can see the entire list of entries registered at this start.

Grub Customizer

What we have to do is simply choose the version that we want to start as default from this program. We can also organize these entries as we like, eliminating the ones we don’t want to appear at startup and placing, outside the “Advanced Option” group, the ones we want to have more at hand.

Remove outdated or corrupt kernels

Once we have confirmed that a particular kernel version works without problems, then it is time to make it the main version. And, after that, we must remove all other versions of this kernel to avoid getting confused and using a version that we do not want, and, incidentally, free up space on the hard disk.

This can be done in various ways, depending on the distribution we use. In the case of Ubuntu, and other distros based on it, we must see the list of installed kernels by executing the following command in the console:

apt list --installed | grep linux-image

In this list we will see all the versions of the Kernel installed.

See List of Installed Kernels

Now, what we will do is point to the name of the kernel, up to the slash / that appears, and execute the following command to delete said kernel:

sudo apt remove [nombre_kernel]

We confirm the deletion, and wait for the process to complete. We will have to repeat it as many times as we want, once for each nucleus that we want to eliminate.

For distros based on Arch, we will have to remove these kernels in a similar way, but using the Pacman package manager as follows:

sudo pacman -S kernel-name=x.x.x kernel-name-headers=x.x.x

same as in Fedora, we will have to do it with RPM:

rpm -qa kernel-core sudo dnf remove kernel-core-x.x.x-xxx.fcxx.x86_64

Lastly, the one that makes it easier for us is Linux Mint. This distro, based on Ubuntu, comes standard with a series of tools designed to make life easier for users. And, among them, the most interesting is the operating system update manager. Within this update manager we will find a section specially designed to configure the kernels, choose the one we want to use, and eliminate the ones we are not going to use.

Leave a comment

Your email address will not be published. Required fields are marked *