How can I change the number of kernels retained when updating in Fedora?

When running ‘dnf update’ the system will only keep 3 of the previous kernel versions installed. Once I attempt to install the 4th update then dnf wants to remove the oldest installed kernel (first in, first out). How can I increase or decrease the number of available/installed kernels?

5 Likes

Edit the file /etc/dnf/dnf.conf, changing the numeric value in installonly_limit=3 to a number of your choice.

Be aware that if you increase the number too high then you run the risk of filling up the /boot partition.

Edit Dec. 2024: f41 ships dnf5, which makes use of drop-in repo directories. Using the old /etc/dnf/dnf.conf config file would still work, but you better place your config in /etc/dnf/libdnf5.conf.d/10-user-settings.conf. Put installonly_limit=<x> in the [Main] section of the config file

Using and configuring dnf is well described in DNF5 Configuration Reference — dnf5 documentation

9 Likes

Very handy. Never thought about this, but this makes going back very easy. :+1:

1 Like

Because this is one of the top search results, I’m going to put here that this has also been asked at SE’s SU, which is going to be more reliable (because it can be indefinitely updated, like MediaWiki):

I’ve updated the information provided in the solution to reflect the changes that came with the introduction of dnf5 in Fedora 41. I also added a link to the official dnf5 documentation, which is probably the most reliable and most up-to-date answer to the question.

3 Likes