Web agency » Digital news » How to restore the kernel in Linux

How to restore the kernel in Linux

If your Linux PC suddenly has problems after updating your system, it is possible that a Linux kernel update is involved. Fortunately, it's relatively easy to roll back or switch to a different kernel on Debian, Arch, and Fedora systems. Here's how.

Why kernel upgrades cause problems

The kernel is an integral part of a Linux system, so depending on your device and configuration, a kernel update can potentially cause problems for you or your installed applications. Problems can range from bizarre graphics behavior to a completely unusable system. If your situation is the latter, you are in real trouble.

To remedy this problem, many modern distributions keep an older or different kernel installed which you can access at boot. These will allow you to test the kernel for problems or recover from a kernel update that breaks the system.

How to check the version of Linux kernel and operating system

How to start with a different kernel

Of course, updates to system packages other than the Linux kernel could be the real root of your problem. A quick way to rule out the kernel as being at fault is to try booting with a different kernel.

You will first need to access your GRUB menu by restarting your PC. You may see GRUB appear for a few seconds at startup, displaying some options such as "Advanced options", although some distributions keep it hidden unless you access it. If it does not appear on startup, hold down the Shift key as your PC starts to boot, until you see a screen similar to the image below.

GRUB menu options for Debian 11 Bullseye

Use the arrow keys to navigate to “Advanced options for [Your Distro]” and press Enter.

You will get a list of available boot options. You should see at least two, like "[Your Distro], with Linux 5.10.0.7-amd64" followed by a "recovery mode" version of that same option. The different versions that you see listed are the different kernels installed.

how-to-restore-kernel-under-linux-6194063-9203177

If you only have one standard option and one recovery mode option, unfortunately that means you only have one kernel installed. In this case, and if you cannot use the kernel at all, you can use recovery mode to try out some repair options.

If you have more than one version number, you have an alternate kernel to boot with. The first option will be the most recent and the one with which your PC starts automatically. Try another non-recovery mode option by navigating it with the arrow keys and pressing Enter.

How to Fix an Ubuntu System When It Won't Boot

How to remove or downgrade a kernel

If booting into another kernel seems to have solved your problem, you will probably want to continue using that kernel. However, your PC may by default try to use the problematic kernel on every boot. You can either manually choose the old kernel on each boot, or delete the problematic kernel while waiting for another update.

Warning: Kernel updates may involve security fixes. For this reason, ignoring kernel updates is risky. If you must continue, make sure that your system is otherwise as secure as possible.

Some distributions allow you to do this graphically, and they may even allow you to simply choose a different kernel by default. For example, Linux Mint's update manager (shown below) has a kernel settings feature that allows you to set kernel preferences in addition to removing unwanted kernels.

Try searching for the word "kernel" in your application menu and see if any desktop tools appear. If so, you can probably do it graphically. Otherwise, read on to remove a kernel via the command line.

Warning: Continue only while booting into the kernel you want to use, not the one you plan to remove.

Removing a kernel on Debian and Ubuntu

To remove a Linux kernel on Debian, Ubuntu, or one of their derivatives, you must first identify the installed kernel packages. Open a terminal and enter the following command.

dpkg --list | grep linux-image

how-to-restore-kernel-under-linux-3874765-8931386

You can see by the package names which version is the most recent. After getting the name of the kernel you want to remove, issue the following command, replacing kernel-name with the name of the kernel package exactly as it appeared in the previous command.

sudo apt remove kernel-name

You will be asked for your password, then you will be asked to confirm the deletion by typing y and pressing Enter.

how-to-restore-kernel-under-linux-9993247-6851857

Wait for the removal to complete and your Linux PC will no longer boot into this kernel. Keep an eye out for new kernels when you update your system and test them as soon as they arrive to see if your issue is resolved.

How to update Ubuntu Linux

Remove or downgrade a kernel on Arch

On Arch Linux, you can easily get multiple alternative kernels with names like linux-hardened , linux-zen , and linux-lts. When choosing an option in GRUB, you have probably only seen one version of each installed kernel available. Unlike kernels on Debian, Arch kernel updates do not come as new packages to replace old ones. Instead, each installed kernel is simply updated (or "synced") to the latest version as soon as it becomes available.

For this reason, it's best to just start with an alternate kernel instead of downgrading your regular kernel. If you have booted into another kernel and know you don't want to use the first one, you can name the kernel in an uninstall command with Pacman.

sudo pacman -R kernel-name name-kernel-headers

Replacement kernel-name with the core of your choice. You will be prompted to enter your password before you can continue. Then you will need to confirm the deletion by typing "y" and pressing Enter.

how-to-restore-kernel-under-linux-1555276-2650050

If you want demote a kernel package, be aware that we do not recommend it. Continuous version updates often rely on updating other packages. Therefore, rolling back any update is a risky activity and can cause the operating system to crash.

If you are sure you want to, however, you can sync a kernel package to a specific version with the following command.

sudo pacman -S kernel-name=xxx kernel-name-headers=xxx

Replace kernel-name with the kernel you want to downgrade and x.x.x with the version you want. You can find older version numbers by searching for the kernel in Arch Package Search and clicking "Show changes".

How to update Arch Linux

Remove a kernel on Fedora

Fedora Linux keeps two older versions of the kernel installed on your device by default as well as the most recent one. With that rpm command, you can identify the names of the packages.

rpm -qa kernel-core

You will see a list of all installed kernels next to their version numbers.

Search for Linux kernels in the Fedora terminal

After booting with a different kernel, use dnf to uninstall the problematic kernel.

sudo dnf remove kernel-core-xxx-xxx.fcxx.x86_64

You will receive a prompt to confirm the uninstallation. Type y and press Enter to confirm.

how-to-restore-kernel-under-linux-8346329-9055880

After removing the kernel, your system will not be able to boot into a newer kernel until you authorize a kernel update. When a new one is available, try it and see if your issue has been resolved.

★ ★ ★ ★ ★