Skip to main content Logo

Quis custodiet ipsos custodes?
Home | About | All pages | Cluster Status | RSS Feed

Remove unused CentOS/Red Hat kernels

Published: 18-01-2014 | Author: Remy van Elst | Text only version of this article

❗ This post is over ten years old. It may no longer be up to date. Opinions may have changed.

This small article will show you how to remove unused kernels in Red Hat or CentOS. This is sometimes necessary because the /boot partition can fill up.

Are you running Ubuntu and want to clean up kernels? See this article: Old Ubuntu_Kernels.html

Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:

I'm developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $200 credit for 60 days. Spend $25 after your credit expires and I'll get $25!

You can check which kernels you have installed using the rpm -q kernel command:

$ rpm -q kernel

As you can see this is a CentOS 5 box.

In the yum-utils package there is the package-cleanup command. This command, among other things, lets you remove older kernels very simple. First install it:

yum install yum-utils

With the following command you can clean up all old kernels and keep just two. The current one and the previous one:

package-cleanup --oldkernels --count=2

The Fedora Documentation has more info and various good examples on the package-cleanup command: US/Fedora/14/html/Software Management Guide/ch07s03.html

Tags: bash , centos , kernel , rhel , snippets , yum