According to man dnf.conf
(which already refers to dnf5.conf - DNF5 Configuration Reference
and therefore seems to have been already updated to dnf5), this has not changed compared to the old dnf:
In the file /etc/dnf/dnf.conf
you have a line with installonly_limit
. By default, this should be installonly_limit=3
I presume. E.g., I have set this on my system to 5 (installonly_limit=5
), which means that it retains 5 kernels, and no longer only 3.
If you increase the number, you will see in the next update if it works: you currently have 3 kernels installed (I presume), so if this is set to, e.g., 4, then it will not delete any kernel when installing the next one.
Don’t forget that on most installations, /boot is a separated partition. So ensure that /boot has sufficient space for retaining more than 3 kernels. I have 403 MB left with 5 kernels installed on a /boot with a total of 973 MB (x86_64).