Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

I got a warning of my /boot partition is almost full(85%). What should I do? Can I remove one of the backup kernel? How to do it safely?

My partition right now

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             10321208    719856   9077064   8% /
tmpfs                  4015460         0   4015460   0% /dev/shm
/dev/sda1               101133     80781     15130  85% /boot
/dev/sda8            253782660  47668764 193222404  20% /home
/dev/sda7              1032088    535840    443820  55% /tmp
/dev/sda3             10321208   4823740   4973180  50% /usr
/dev/sda5             10321208   1807284   7989636  19% /var

The Kernel I have

root@server1 [/boot]# rpm -q kernel
kernel-2.6.32-358.el6.x86_64
kernel-2.6.32-358.18.1.el6.x86_64
kernel-2.6.32-358.23.2.el6.x86_64

The /Boot directory

root@server1 [/boot]# ls -la /boot
total 78741
dr-xr-xr-x.  5 root root     2048 Dec  3 05:33 ./
drwxr-xr-x. 23 root root     4096 Dec  4 05:46 ../
-rw-r--r--   1 root root   104112 Aug 28 12:43 config-2.6.32-358.18.1.el6.x86_64
-rw-r--r--   1 root root   104112 Oct 16 14:01 config-2.6.32-358.23.2.el6.x86_64
-rw-r--r--.  1 root root   104081 Feb 21  2013 config-2.6.32-358.el6.x86_64
drwxr-xr-x.  3 root root     1024 Sep 20 20:15 efi/
drwxr-xr-x.  2 root root     1024 Oct 21 15:06 grub/
-rw-r--r--   1 root root 16191847 Sep 20 20:21 initramfs-2.6.32-358.18.1.el6.x86_64.img
-rw-r--r--   1 root root 16261655 Oct 21 15:06 initramfs-2.6.32-358.23.2.el6.x86_64.img
-rw-r--r--.  1 root root 16187335 Sep 20 20:16 initramfs-2.6.32-358.el6.x86_64.img
-rw-------   1 root root  3698835 Sep 20 20:27 initrd-2.6.32-358.18.1.el6.x86_64kdump.img
-rw-------   1 root root  3983771 Dec  3 05:33 initrd-2.6.32-358.23.2.el6.x86_64kdump.img
-rw-------   1 root root  3695290 Sep 20 20:21 initrd-2.6.32-358.el6.x86_64kdump.img
drwx------.  2 root root    12288 Sep 20 20:13 lost+found/
-rw-r--r--   1 root root   185949 Aug 28 12:44 symvers-2.6.32-358.18.1.el6.x86_64.gz
-rw-r--r--   1 root root   185978 Oct 16 14:02 symvers-2.6.32-358.23.2.el6.x86_64.gz
-rw-r--r--.  1 root root   185734 Feb 21  2013 symvers-2.6.32-358.el6.x86_64.gz
-rw-r--r--   1 root root  2408641 Aug 28 12:43 System.map-2.6.32-358.18.1.el6.x86_64
-rw-r--r--   1 root root  2408974 Oct 16 14:01 System.map-2.6.32-358.23.2.el6.x86_64
-rw-r--r--.  1 root root  2407466 Feb 21  2013 System.map-2.6.32-358.el6.x86_64
-rwxr-xr-x   1 root root  4046224 Aug 28 12:43 vmlinuz-2.6.32-358.18.1.el6.x86_64*
-rw-r--r--   1 root root      171 Aug 28 12:43 .vmlinuz-2.6.32-358.18.1.el6.x86_64.hmac
-rwxr-xr-x   1 root root  4047152 Oct 16 14:01 vmlinuz-2.6.32-358.23.2.el6.x86_64*
-rw-r--r--   1 root root      171 Oct 16 14:01 .vmlinuz-2.6.32-358.23.2.el6.x86_64.hmac
-rwxr-xr-x.  1 root root  4043888 Feb 21  2013 vmlinuz-2.6.32-358.el6.x86_64*
-rw-r--r--.  1 root root      166 Feb 21  2013 .vmlinuz-2.6.32-358.el6.x86_64.hmac

The Kernel I'm using

root@server1 [/boot]# uname -a
Linux server1 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
share|improve this question

marked as duplicate by slm, Karlson, jasonwryan, rahmu, bahamat Dec 14 '13 at 2:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers 3

up vote 4 down vote accepted

Do the following to keep just the last 2 kernels on your system, to keep /boot clean

1 - Edit /etc/yum.conf and set the following parameter

installonly_limit=2

This will make your package manager keep just the 2 last kernels on your system(including the one that is running)

2 - Install yum-utils:

yum install yum-utils

3- Make an oldkernel cleanup:

package-cleanup --oldkernels --count=2

Done. This will erase in a good fashion the old kernels, and, keep just the last 2 of them for the next upgrades.

share|improve this answer
    
Thanks nwildner! Can I do it right now? Do I need to reboot the system after doing that? Do I need to backup all my data? –  Don Li Dec 13 '13 at 16:06
    
Yes you can. A backup of your /boot, just for precaution could be a good thing to do. You will not need to reboot, since the step 3 will erase the oldest kernel, unless you are running it right now. The first step, will make this configuration permanent ;) –  nwildner Dec 13 '13 at 16:44

You can delete old kernels safely by doing the following:

# Install the yum-utils if they aren't installed
yum install yum-utils
# Cleanup old kernels and don't keep more than 2
package-cleanup --oldkernels --count=2

And should you wish, you can limit this always by doing the following in /etc/yum.conf

installonly_limit=2
share|improve this answer
    
After seeing Joel Davis's answer, I would also agree with him. Check to see what really is using all that space. –  sparticvs Dec 13 '13 at 15:48
    
If you look at his ls and add up the files, it's about 25MB per kernel, mostly in initramfs. –  cjm Dec 13 '13 at 15:58
    
Yea, I had a feeling it might be the initramfs files. The cleanup above should remove those as well. –  sparticvs Dec 13 '13 at 15:59
    
@sparticvs, I checked -rw-r--r-- 1 root root 16191847 Sep 20 20:21 initramfs-2.6.32-358.18.1.el6.x86_64.img -rw-r--r-- 1 root root 16261655 Oct 21 15:06 initramfs-2.6.32-358.23.2.el6.x86_64.img -rw-r--r--. 1 root root 16187335 Sep 20 20:16 initramfs-2.6.32-358.el6.x86_64.img use a lot of space. –  Don Li Dec 13 '13 at 16:03
    
@sparticvs, can I do it right now? Do I need to reboot the system after doing that? Do I need to backup all my data? –  Don Li Dec 13 '13 at 16:05

Kernel images are actually really small:

[root@ditirlns01 ~]# ls -lh /boot/vmlinuz-2.6.18-3*
-rw-r--r-- 1 root root 2.2M May  4  2012 /boot/vmlinuz-2.6.18-308.8.1.el5xen
-rw-r--r-- 1 root root 2.2M Jul 27 01:43 /boot/vmlinuz-2.6.18-348.16.1.el5xen
-rw-r--r-- 1 root root 2.2M Mar 22  2013 /boot/vmlinuz-2.6.18-348.4.1.el5xen

There's more to the kernel package, obviously, but that's the part that's on /boot which is what your concern is.

So with a 100MB /boot partition, deleting a 2-3MB kernel probably isn't going to get you very far.

100MB is actually usually way more than people need. I would do enough du -sh invocations so you can see what's taking up all that space, because you shouldn't even be getting kind of close to using 100MB on that mount point:

[root@ditirlns01 ~]# df -h /boot
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1             99M   34M   60M  37% /boot

Which is with three kernels installed:

[root@ditirlns01 ~]# rpm -qa kernel*
kernel-xen-2.6.18-348.16.1.el5
kernel-xen-2.6.18-348.4.1.el5
kernel-headers-2.6.18-348.16.1.el5
kernel-xen-2.6.18-308.8.1.el5
[root@ditirlns01 ~]#

I'm willing to wager that someone put a file on /boot as a temporary move and forgot to move it back off later on.

share|improve this answer
2  
But there are the initramfs files, that are way bigger than the kernel files. Looking at @Don ls, they use 14MB. –  nwildner Dec 13 '13 at 15:48
    
ah yeah I'm seeing that now. Oh well, I'll leave my answer up and just upvote your guys' –  Joel Davis Dec 13 '13 at 15:53

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