Put Fedora kernel on HOLD to prevent its removal on updates

In Ubuntu, I have put the few kernels that work flawlessly ON HOLD (locks it to prevent updater from removing them) by using these commands:

First, I use “dpkg --list | grep linux-image” as this will show a list of installed kernel packages, such as linux-image-6.8.0-85-generic…

Then I pick the kernel that I want to KEEP ALWAYS:

"apt-mark hold ‘kernel-package name’ "

doesn’t work on Fedora…

1 Like

Not possible in Fedora. It isn’t straightforward. If you still want to get new kernels and keep some you’ll have to do manual kernel removal like sudo dnf remove kernel*6.12.77* kernel*6.19.9* from time to time and prevent dnf from auto removing then by putting in your /etc/dnf/dnf.conf installonly_limit=5 to keep 5 kernels max because of limited disk space in /boot. 5 is a suggestion. Remove unneeded kernels manually before dns starts to do it.

You could also set it to 0 instead of 5 to disable it completely. In such a case you are required to remove kernels manually to prevent eating up all disk space which would render your system unbootable.

1 Like

There is the dnf versionlock plugin that should do the trick, although I’ve not used it with the kernel package:

versionlock doesnt work for kernel unfortunately: versionlock: ignored for `kernel` upgrade · Issue #2368 · rpm-software-management/dnf5 · GitHub

You could try, though someone mentioned that this isnt possible either Perfect Fedora WS - how to "pin" a specific kernel - #8 by anothermindbomb

1 Like

I was aware of versionlock however a recent discussion mentioned it doesn’t work with kernels so I didn’t suggest it. I never tested it myself though.

2 Likes

OK - Thanks!

That’ll work: I put installonly_limit=0 in my /etc/dnf/dnf.conf, and we’ll just dump the ones that I have issues with (none so far)

my /boot is 2Gb w/1.5Gb free, so plenty of room for now - will keep watch on it

:wink:

1 Like

Ditto. Happy you figured it out. Good luck!

1 Like