How does one determine which kernels to remove in order to free up some space on /boot partition.

Here is a scenario (some background info).

1. Parititon info (in case it helps)

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        99M   81M   14M  86% /boot

2. Current kernel version

# uname -a
Linux serv.example.com 2.6.32-358.23.2.el6.x86_64 #1 SMP Wed Oct 16 18:37:12 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

3. All kernel versions installed

# rpm -qa | grep kernel


  1. Which kernel versions would one remove from the list above?
  2. How?
  3. A short explanation on the decision (why?) would help.
  • @MichaelHampton: That question doesn't have the best answers (up-to-date & easier ways). Jason Zhu, gave an excellent answer (IMHO) below. No need to do the monkey job of figuring out the versions anymore. – Shef Dec 17 '13 at 21:38
  • Jason, I think Shef has a point; please consider visiting the duplicate references above and submitting your answer there, as I think it would add something valuable to the definitive question on the subject. – MadHatter Dec 18 '13 at 8:42

Taken from the following website

## Install yum utils ##
yum install yum-utils

## Package-cleanup set count as how many old kernels you want left ##
package-cleanup --oldkernels --count=2

This will remove all older kernels and keep only the two most recent kernels on centos 6.4 which is probably what you want since recent kernels contain bug fixes and you can always failover to the older kernels if the new ones fail to boot. The above command means that you don't have to go and say rpm -e xyz where xyz is your specific kernel since it automatically keeps the newest ones.

The command you ran

rpm -qa | grep kernel

Doesn't actually tell you what kernels are using space on your boot partition. dracut-kernel doesn't actually install a kernel on your system. You can query the rpm to confirm that.

[root@localhost]: rpm -ql dracut-kernel
| improve this answer | |
  • This worked fine on RHEL7 as well. +1. – a coder Jun 2 '16 at 18:33

I'd remove all but the most recent two. You need the one you're running right now, of course, but I think it's worth keeping one previous one in case there are some stability issues with the current one. You'd have something to go back to in a hurry if that were the case.

rpm -ev kernel-2.6.32-358

If you're confident of the stability of the current one, and you really want that space back, remove the second newest one with

rpm -ev kernel-2.6.32-358.11.1
| improve this answer | |
  • Thanks. +1'ed you, but @JasonZhu gave a better (automated) way. And he does need some reps... :) – Shef Dec 17 '13 at 21:34
  • Not to worry; I agree with you! – MadHatter Dec 18 '13 at 8:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.