How to back up the kernel in Linux

How to back up the kernel in Linux

fatmawati achmad zaenuri /

If your Linux pc suddenly has problems after updating your system, it is possible that a Linux kernel update is to blame. Fortunately, rolling back or switching to another kernel on Debian, Arch, and Fedora systems is relatively easy. Here’s how you do it.

Why kernel upgrades cause problems

The kernel is an integral part of a Linux system, so depending on your device and setup, a kernel update has the potential to cause problems for you or your installed applications. Questions can range from whimsical graphics behavior to a completely useless system. If your situation is the latter, you are in a real pickle.

To remedy this problem, many modern distros keep an older or other kernel installed that you can access at startup. These allow you to test the kernel for issues or recover from a system-breaking kernel update.

RELATED: How to check the Linux kernel and operating system version

How to start with another kernel

Of course, updates to system packages other than the Linux kernel may be the true root of your problem. A quick way to rule out that the kernel is to blame is to try to start with another kernel.

You must first access your GRUB menu by restarting your PC. You may see GRUB appear for a few seconds at startup and display a few options such as “Advanced Settings”, although some distros keep it hidden unless you access it. If it does not appear at startup, press and hold the Shift key the moment your PC starts to boot until you see a screen similar to the image below.

GRUB menu settings for Debian 11 Bullseye

Use the arrow keys to navigate to “Advanced Settings for [Your Distro]And press Enter.

You will get a list of available boot options. You must see at least two that “[Your Distro], with Linux ”followed by a“ recovery mode ”version of the same option. The different versions you see in the list are the different cores that are installed.

Two cores with recovery mode settings set as boot options in GRUB on Debian 11

Unfortunately, having only one default setting and one restore feature means that you have only one kernel installed. In that case, and if you can not use the kernel at all, you can use the recovery feature to try some repair options.

If you have more than one version number, you have an alternate kernel to start with. The first option is the newest and the one your PC automatically starts with. Try another non-recovery option by navigating to it with the arrow keys and pressing Enter.

RELATED: How to repair an Ubuntu system when it does not start

How to remove or downgrade a kernel

If booting to another kernel seems to have solved your problem, you will probably continue to use that kernel. However, by default, your PC may try to use the problematic kernel every time you start. You can either manually select the older kernel at each startup or delete the problematic kernel while waiting for another update.

Warning: Kernel updates may involve security fixes. For this reason, there are risks associated with ignoring kernel updates. If you need to continue, make sure your system is otherwise as secure as possible.

Some distros allow you to do this graphically, and they may even let you simply select another kernel by default. For example, Linux Mint’s Update Manager (pictured below) has a kernel settings feature that allows you to specify kernel preferences in addition to deleting unwanted kernels.

Try searching for the word “core” in your application menu and see if there are any desktop tools available. If one does, you will probably be able to do this graphically. Otherwise, read on to delete a kernel through the command line.

Warning: Only continue while you have started up in the kernel you want to use, not the one you plan to remove.

Remove 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

Search for Linux kernel names using the grip command

You can look at package names to see which version is the latest. After getting the name of the kernel you want to remove, send the following command and replace kernel-name with the kernel package name exactly as it appeared in the previous command.

sudo apt remove kernel-name

You will be asked for your password and then asked to confirm the removal by typing y and press enter.

Use the appropriate tool to remove a specific kernel version

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

RELATED: How to update Ubuntu Linux

Remove or downgrade a kernel on Arch

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

For that reason, it is best to start with an alternative kernel instead of downgrading your usual kernel. If you have booted into a second kernel and know you do not want to use the first one, you can name the kernel in an uninstall command with Pacman.

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

Replacement kernel-name with the core of your choice. You will be asked for your password before you can proceed. Then confirm the removal by typing “y” and pressing enter.

Use pacman to uninstall kernels in Arch Linux

If you want downgrade a core package, in that we do not recommend it. Updates to rolling releases are often dependent on other packages being updated, so revoking any update is a risky business and could result in a corrupted operating system.

However, if you are sure you want to, you can synchronize a kernel package to a specific version with the following command.

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

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 looking up the core in Arch Package Search and clicking “View Changes.”

RELATED: How to update Arch Linux

Remove a kernel on Fedora

By default, Fedora Linux keeps two older versions of the kernel installed on your device along with the latest one. With this rpm command, you can identify the package names.

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 starting up with another kernel, use dnf to uninstall the problematic kernel.

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

You will get a prompt to confirm the uninstallation. Type y and press enter to confirm.

Remove the kernel from the Fedora Linux terminal

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

Leave a Comment