Remove unused CentOS/Red Hat kernels

18-01-2014 | Remy van Elst

This small article will show you how to remove unused kernels in Red Hat or CentOS. This is sometimes necessary because the /boot partition can fill up.

Are you running Ubuntu and want to clean up kernels? See this article:

You can check which kernels you have installed using the rpm -q kernel command:

$ rpm -q kernel

As you can see this is a CentOS 5 box.

In the yum-utils package there is the package-cleanup command. This command, among other things, lets you remove older kernels very simple. First install it:

yum install yum-utils

With the following command you can clean up all old kernels and keep just two. The current one and the previous one:

package-cleanup --oldkernels --count=2

The Fedora Documentation has more info and various good examples on the package-cleanup command:

Tags: bash,centos,kernel,rhel,yum,