How To Remove Old Kernels In CentOS


Ever had the the “no space left” message after trying to install a new kernel ?

The thing is that by default the system will keep the old kernels there, so the best option is to set it to delete the old ones automatically.

Starting from the beginning: For one self information, check how many kernels you do have with:

root@server [~]# rpm -q kernel

Result is something similar to this

kernel-2.6.32-431.el6.x86_64
kernel-2.6.32-431.3.1.el6.x86_64
kernel-2.6.32-431.5.1.el6.x86_64

Now you install the yum tools:

yum install yum-utils

and finally you setup so that you keep only the last 2 kernels

package-cleanup --oldkernels -count=2

If you get the message that you have unfinished transactions, just accept it, and once all is configured and set, run a yum upgrade to get the latest one.

Have fun!

One thought on “How To Remove Old Kernels In CentOS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s