[CentOS] Safe method to remove old kernels

Michael Kratz mkratz at internode.com.au
Fri Oct 12 13:36:59 UTC 2007

On 12/10/2007, at 10:53 PM, Scott Moseman wrote:

> # rpm -qa | grep kernel-2 | sort
> kernel-2.6.9-42.0.10.EL
> kernel-2.6.9-42.0.2.EL
> kernel-2.6.9-42.0.3.EL
> kernel-2.6.9-42.0.8.EL
> kernel-2.6.9-42.EL
> kernel-2.6.9-55.0.2.EL
> kernel-2.6.9-55.0.6.EL
> kernel-2.6.9-55.0.9.EL
> kernel-2.6.9-55.EL
> I'm running the most recent kernel available, and I've never had a
> problem with any past kernels, so I don't believe there's any reason
> to keep all of them.  I guess kernels get a fresh install instead of
> an upgrade?  Can I safely rpm-e the old kernel packages?  Should this
> be something I do through yum instead?

Yep, you just do (for example)

yum remove kernel-2.6.9-42.0.10

i.e. specify the exact version in the remove statement.

Be very very careful... don't remove the kernel you're running.

this should also remove the entries in your grub.conf, but check it  
once you're done.

> Some of my CentOS servers have even more old kernels than this sample.

You might be able to remove a bunch of them in one go if you do  
something like:

yum remove kernel-2.6.9-42*

again, be careful, double check what you're doing, don't make a silly  
mistake and remove the wrong kernel(s)

Note: if you've installed any RPM modules that depend on specific  
versions of kernels, yum will (correctly) want to remove those too.



More information about the CentOS mailing list