Stop DNF from keeping every old kernel version you ever installed

Package Management & Distro Internals (Apt/Dnf/Pacman)

Stop DNF from keeping every old kernel version you ever installed

Technical Briefing | 11/21/2026

I checked a production node last week and realized it had been holding onto seventeen different kernel versions. Seventeen. My root partition was gasping for air, and it turned out DNF was just doing what it was told: keeping the last three installed kernels, plus whatever else happened to be lingering around. Most admins never bother tuning the installonly_limit because the defaults usually work until they suddenly don’t.

Why DNF hoards your storage

The setting controlling this is buried in your dnf.conf. If you look at it, you’ll see a value for installonly_limit. By default, it is set to 3. That means you always have the running kernel and two backups. If you do frequent updates or have a messy build environment, those headers and modules add up to gigabytes of useless weight. If you’ve never touched this, check your current configuration.

grep -E "^installonly_limit" /etc/dnf/dnf.conf

  • Setting this to 2 is the sweet spot for most production servers
  • Setting it to 1 is risky but fine if you have a stable recovery plan
  • DNF will automatically prune older kernels during the next transaction

If you are low on disk space right now, changing the config isn’t enough; that only stops future bloat. You have to clean up the existing mess manually. Run package-cleanup if you want to reclaim that space immediately without waiting for the next kernel update cycle. Next time your monitoring alerts on disk pressure, check /boot before you go looking for actual data hogs.

Linux Admin Automation  |  © www.ngelinux.com  |  11/21/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted