YUM/DNF Remove Old Kernels on Fedora/CentOS/RHEL

This is quick guide howto delete/remove/clean old kernels on Fedora, CentOS, Red Hat (RHEL). I use here two kernel as example, if you want to keep other more or less, then adjust amount of installed kernels as you wish. Normally reason why you maybe want remove kernels is limited disk space, example on VPS servers and laptop. This is very easy task, you need yum-utils package.

1. Check Installed Kernels

rpm -q kernel

2. Delete / Remove Old Kernels

## Install yum-utils ##
## Fedora 25/24/23/22 ##
dnf install yum-utils

## Fedora 21/20/19/18/17/16, CentOS, Red Hat (RHEL) ##
yum install yum-utils

## Package-cleanup set count as how many old kernels you want left ##
package-cleanup --oldkernels --count=2

3. Make Amount of Installed Kernels Permanent

Edit /etc/yum.conf or /etc/dnf/dnf.conf and set installonly_limit:


26 comments on “YUM/DNF Remove Old Kernels on Fedora/CentOS/RHEL

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.