Remove old kernels on Fedora/Centos/RHEL
Posted by hsukumar on 25/04/2009
First I figure out what kernel I am actually running now so I don’t try and delete it. I am not sure what would happen if I tried but I am not going to find out. To determine the running kernel, use uname -r. I am running 2.4.21-52.ELsmp .
Next we want to see what other kernels are installed to find what we can delete. Do this like so:
[root@localhost root]# rpm -q kernel kernel-2.4.21-37.EL kernel-2.4.21-37.0.1.EL kernel-2.4.21-40.EL kernel-2.4.21-47.EL kernel-2.4.21-47.0.1.EL kernel-2.4.21-50.EL kernel-2.4.21-51.EL kernel-2.4.21-52.EL
I see that we have 7 old kernels installed. Now to delete them, just use rpm -e like so:
rpm -e kernel-2.4.21-37.EL
or you can use yum remove < kernel>
or more fany stuff is to use this command
yum remove $(rpm -qa | grep kernel | grep -v `uname -r`)
This will remove all the old kernel except the current one