How to remove old kernels on CentOS 6 (to free up boot partition)? [duplicate]

Taken from the following website

## Install yum utils ##
yum install yum-utils

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

This will remove all older kernels and keep only the two most recent kernels on centos 6.4 which is probably what you want since recent kernels contain bug fixes and you can always failover to the older kernels if the new ones fail to boot. The above command means that you don’t have to go and say rpm -e xyz where xyz is your specific kernel since it automatically keeps the newest ones.

The command you ran

rpm -qa | grep kernel

Doesn’t actually tell you what kernels are using space on your boot partition. dracut-kernel doesn’t actually install a kernel on your system. You can query the rpm to confirm that.

[root@localhost]: rpm -ql dracut-kernel
/usr/share/doc/dracut-kernel-004
/usr/share/doc/dracut-kernel-004/README.kernel

Leave a Comment