November 7, 2014 · centos fedora kernel learnshell linux rhel server tricks vps yum

Remove Old Kernels on RHEL, CentOS, Fedora

centos-logo-gfx

This is quick guide howto remove old kernels on Red Hat and it's brothers - Fedora and CentOS. I will also show how to prevent the system from taking up space with old kernels by limiting the number of kernels to be kept to just two.

The reason why you may want remove kernels is limited disk space, e.g. on VPS or a small boot partition.

First of all, let's install yum-utils package:

root@server $ yum install yum-utils

Next, let's check how many old kernels there are on our system:

root@server $ rpm -q kernel kernel-2.6.32-220.2.1.el6.i686 kernel-2.6.32-220.4.1.el6.i686 kernel-2.6.32-220.4.2.el6.i686 kernel-2.6.32-220.7.1.el6.i686

Remove the old kernels and leave just two most recent ones:

root@machine $ package-cleanup --oldkernels --count=2

And, one more touch, prevent the system from leaving old kernels, elaving just two latest ones, by editing /etc/yum.conf. Edit the line:

installonly_limit

and set desired limit.

And that's it! Enjoy more free space on your disk!

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket

Contact