HOW TO: Remove old kernels in CentOS & RHEL

Removing older kernels in CentOS, RedHat Linux (RHEL), or Scientific Linux is really easy, if you know how!
Yum provides a package called “yum-utils” that provides a kernel cleanup utility. So you will need to install this package first.

Manually remove older kernels

Install yum-utils

sudo install yum-utils

Check which kernels you have installed:

rpm -q kernel

Remove all but the oldest two kernels (you can change this number depending on how many kernels you wish to keep):

package-cleanup --oldkernels --count=2

Optional: Automatically remove kernels in the future

You can also make it so that yum will automatically remove older kernels the next time you update your kernel.

Edit /etc/yum.conf:

Find the line ‘installonly_limit” and set it to 2 (or whichever number of kernels you wish to keep):


Be the first to comment

Leave a Reply

Your email address will not be published.