Self-upgrading kernel and compatibility issues

Hi, today I would like to ask the Fedora community a question.
Having the automatic switch to new kernel versions is certainly a great convenience and allows you to have a system that remains modern over time. However, it may happen that at a certain point, the new kernel no longer offers full compatibility with the hardware in use and the user needs to choose a previous version of the kernel (one of those still supported, of course) blocking updates to subsequent versions.

To do this, however, the less experienced user must make do as best he can, as there is no official step-by-step guide that allows you to easily achieve this result and there is not even a graphical tool (such as is present on Manjaro and some other distributions) that can make up for this lack.

What do you think about this? Do you think it is more useful to have a step-by-step guide that allows you to achieve the goal through the use of the terminal or that it is better to have a graphical tool, perhaps written in GTK?

The problem is that it’s not a planned change that breaks support for hardware.
So you only know that it’s a problem when a user reports the issue.
And by that point in time it’s too late to prevent the new kernel being used.

Personally I accept the risk of a new kernel causing a very rare issue.
But then I have the experience to debug when such a situation happens.
It’s usually not the kernel that has affected me in the past.
For example I had a problem with disk mounting that was down to a mistake I made in config. But it only became an issue with I upgraded to f41.

1 Like

The process is relatively straightforward, you can add the kernel* packages to an exclude line in /etc/dnf/dnf.conf:

exclude=kernel*

In this case the kernel won’t be updated anymore.

As an alternative, the currently booted kernel will not be replaced when doing upgrades. So if you set the preferred kernel as your default boot kernel, it should not be replaced by newer kernels.

To set the default kernel you can first list the installed kernels:

$ sudo sh -c 'grep title /boot/loader/entries/* | cut -d " " -f2-'

Fedora Linux (0-rescue-ed061c9f8be1438b8b5b5f3bc9133fd1) 41 (Workstation Edition)
Fedora Linux (6.11.4-301.fc41.x86_64) 41 (Workstation Edition)
Fedora Linux (6.12.10-200.fc41.x86_64) 41 (Workstation Edition)
Fedora Linux (6.12.9-200.fc41.x86_64) 41 (Workstation Edition)

Then add the desired kernel to /etc/default/grub:

GRUB_DEFAULT="Fedora Linux (6.12.10-200.fc41.x86_64) 41 (Workstation Edition)"

Perhaps the above is or could be noted somewhere in the Quick Docs or wiki articles as well.

2 Likes

Not even with a manual update I assume?

Can this be done using Grubby as well?

But this is only part of the problem. In reality, when the critical event occurs, you first need to install an “old” kernel of your choice (because it is not necessarily one of the last three already installed); this already requires changes to the configuration files since the default configuration does not allow the simultaneous installation of more than three kernels. Once this is done, you can proceed in the way you indicated. But all this would be made much simpler with a GUI written specifically for it (as already said, there are already some for other distributions).

When you realize that the problem is due to hardware incompatibility, the best thing to do to use your PC as long as possible is to rely on the LTS version of the kernel that works well and that guarantees updates and support for the longest possible time. Switching to a non-LTS would risk postponing the problem by only a few months, unless a user wants to keep a kernel that is no longer supported. But this is not desirable.

Unfortunately Fedora Linux not calls the Kernel LTS. For us we use main/stable kernel. Because when The kernel gets changed to the next version, it is the next stable kernel for us. Even if it gets listed as LTS on kerenel.org. We not use it so long tat we can name it Long term Support Kernel.

On the release section of kernel-org you can see the LTS Kernel listed, and how long they get support.

If you really want an LTS Kernel for Fedora Linux, you need to take it from Copr. I made good experience with the one from coprs/kwizart/

An other point about overwriting your kernel is, that this just happens when you use the official Fedora kernels from the fedora-updates Repository. If you use a copr kernel, you just overwrite the grub entry, making the latest installed as the active one you will have 4 Kerenl entries and one resque entry. In other words, the one who fedora will boot automatically.

Now the most interesting part is, while knowing that the grub entries get affected while upgrade an Kernel, you can control this with the tool called grubby. If you are interested how to handle the grub entry with a fiev single commands, you can have a look on my notes I made about it, in the wiki.

While using grubby and just fedora kernels from fedora-update and you always use the working kernel, you will never overwrite your “last working one” as long as you set with grubby your last working one, immediately after a new kernel and a reboot.

As explained above, a new from fedora-updates installed kernel, just overwrites, alias

removes kernels, which are not in use while it makes the kernel update!

Before making an update its important to check with uname -a, the kernel version we are on.
And second with grubby sudo grubby --default-title, if this is the one we want to protect from overwriting.

If not, using the procedure mentioned above (see wiki grubby), to make the desired kernel active and reboot, while verifier with uname -a. Now we are ready to do the kernel update and are save not to brake the working one.

1 Like

That’s correct

I don’t use Grubby myself, but this should be the equivalent command:

$ ls /boot/vmlinuz*

/boot/vmlinuz-0-rescue-ed061c9f8be1438b8b5b5f3bc9133fd1
/boot/vmlinuz-6.11.4-301.fc41.x86_64
/boot/vmlinuz-6.12.9-200.fc41.x86_64
/boot/vmlinuz-6.12.10-200.fc41.x86_64

$ sudo grubby --set-default /boot/vmlinuz-6.12.10-200.fc41.x86_64
1 Like

Thanks

Thanks for all the clarifications, suggestions and detailed explanations.

1 Like

You can also use something like this 99-setdefaultkernel.install placed in /usr/lib/kernel/install.d/

#!/usr/bin/bash
#When updating the kernel
#sticky the currently booted kernel
_KERNEL="/boot/vmlinuz-$(uname -r)"
#or sticky a particular version manually
#_KERNEL="/boot/vmlinuz-6.11.10-300.fc41.x86_64"

case "$1" in
    add)
        grubby --set-default="${_KERNEL}"
        ;;
    *)
        ;;
esac

It sets the default kernel back to the booted kernel on update or you can set the kernel version manually. It will still update but will always boot to the old one.

2 Likes

In any case, you must first choose a kernel and possibly install it (if not already present), then modify the dnf.conf file to add an additional slot (or you must uninstall one of those already present. After that you can use this script. I continue to consider a GUI to do this indispensable, in such a modern, refined, and complete distribution.