Fedora regularly offers an updated stable kernel for its users. This is just one of many reasons Fedora is a way to get the newest technology now. On rare occasions, though, a new kernel can bring an issue with it. You might need to revert to an older one to keep things working until the bug is fixed. This article shows you how.
The GRUB menu
Your system has a boot loader called GRUB that manages the start of the boot process. Among other things, it points to the kernels available on your system. However, your configuration might not allow you to see it for long. Often computer manufacturers include their own boot screens during the BIOS (basic input/output system) load process. The GRUB screen is different. It appears after the BIOS has loaded and the computer is ready to start up an operating system.
To make sure you see the GRUB screen, hold down a key like Ctrl after your computer manufacturer screen loads. The GRUB screen appears and shows a menu that includes several kernels.
Typically the top entry is the latest kernel. You can tell by the higher version number displayed in the entry. To select a different entry, use your arrow keys to select the previous version. Then hit Enter to boot that version.
Locking the kernel version
Typically a Fedora system will keep up to three kernel versions installed on the system. When a newer kernel is updated, up to two previous versions are kept on the system. An older kernel beyond those two will be removed by default. That means the boot partition doesn’t fill up to the point it affects the system boot.
Perhaps you want to lock down a specific version and have it always available always. In that case, you can use the versionlock plugin for DNF to keep it installed on the system regardless of updates.
To get the plugin, install the plugin package using sudo:
sudo dnf install python3-dnf-plugins-extras-versionlock
Then add a version lock for the version desired. For example:
sudo dnf versionlock add kernel-4.9.13-200.fc25
If you want to remove the locked version, use the delete option:
sudo dnf versionlock delete kernel-4.9.13-200.fc25
Keep in mind that versionlock works for packages of all kinds.
A note on Atomic Host
These instructions apply to the standard editions, like Fedora Server and Workstation, and most labs and spins. By default, the Atomic Host edition keeps the previous rollback kernel.
Simon
I think you can also exclude any further kernel updates on a system too, with the command:
or by editing and adding the below to the file: /etc/dnf/dnf.conf
exclude=kernel-*
The above approach maybe a bit extreme though, unless you always want to keep your computer on a specific kernel.
With the approach given in the article to versionlock, is there a way to then make that version locked kernel the default one that always boots too? This would save having to select it over whatever new kernel has installed since you version locked (assuming you haven’t blocked kernel updates too ofc!)?
Paul W. Frields
@Simon: Yes. You can do this:
command. This example uses
for the #2 kernel, but you could substitute 3 or whatever instead:
Now you can reboot into the locked kernel. The above process works independently of versionlock. It uses a kernel title instead of a numbered slot, so that if kernel index order changes, the desired default should still boot.
antikythera
the above rewrite command for GRUB only applies for legacy BIOS installations with MBR partition layout.
EFI with GPT layout system users should do the following instead
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
Paul W. Frields
@antikythera: Good catch, thanks!
pawan
Nice info thanks worked.
DonPedro
Or just list them with: grubby –info=ALL
and then: grubby –set-default /boot/kernel version,
like: grubby –set-default /boot/vmlinuz-4.2.0-1.fc23.x86_64.
Here are the docs: https://docs.fedoraproject.org/en-US/Fedora/25/html/System_Administrators_Guide/sec-Making_Persistent_Changes_to_a_GRUB_2_Menu_Using_the_grubby_Tool.html
Paul W. Frields
@DonPedro: Unfortunately that doesn’t seem to work properly on Fedora 26, having tested that here. Have you tested on Fedora 25 to confirm it works?
staff
Didn’t work on fed 25…..
Jim Griffin
I’m afraid I was not clear enough. The only remaining kernels are 4.1.?, so what I need is a way to load an older kernel, from HD, cd, flash, etc., and put it in the file that grub recognizes, and then I can adjust the boot order and get rid of the ones failing. I am now using the rescue kernel, but I’m sure I will find a limitation soon. I really don’t want to start from scratch with a clean install, but I will if that is the only alternative.
Thanks for responding.
Jim Griffin
I updated to kernel 4.10.10-200 and have the three previous, 4.10.9 & 4.10.8. All of these hang at some point after x-windows loads, usually worse on the newest one. How can I find and load and go back to 4.9.14-200 which worked fine? On my system, grubby does not work, but i’m ok with that.