YUM Delete / Remove Old Kernels on Fedora, CentOS, Red Hat (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 ##
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 and set installonly_limit:

Follow If Not True Then False Updates!


  1. Thank you for your article. Instead of installing yum-utils, why not just use “yum erase” on the kernel packages?

    • Hi kkaos,

      You could of course use “yum erase” (from “rpm -q” output), but with yum-utils package-cleanup you can just simply setup count, how many kernels you want to left, without knowing how many kernels you even have. :)

      • Execellent answer ;-)

  2. Thanks for you post

  3. If there is a new kernel and update, the older kernel will be deleted automatically after doing this?

    • Hi Martín,

      Yes, if you use installonly_limit=[number of kernels] in /etc/yum.conf.

  4. thank u .

  5. I went to /var/log/yum.log, spotted the installed file, concatenated all in one line, added yum remove before it and pressed enter, job done, the new failed kernel disappeared. In all cases, make sure you have booted from a kernel that’s not the one you intend to erase….

    • Hi rolandc,

      Little bit different thing, this guide is removing old kernels and keep amount what you want.

      But yes sometimes it’s useful to remove latest kernel too. Normally I just keep broken kernel also and just boot some another working kernel and wait next kernel build.

  6. Short and sweet. I love my Centos.

Add Comment Register

Leave a Comment

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>