17

I am trying to do yum update on RHEL 6 box and I am getting this error message

Transaction Check Error:
  installing package kernel-2.6.32-279.9.1.el6.x86_64 needs 10MB on the /boot filesystem
  installing package grub-1:0.97-77.el6.x86_64 needs 10MB on the /boot filesystem

Error Summary
-------------
Disk Requirements:
  At least 10MB more space needed on the /boot filesystem.

My /boot has the following

# ls -lah /boot
total 74M
dr-xr-xr-x.  5 root root 2.0K Jun 10 08:05 .
drwxr-xr-x. 23 root root 4.0K Aug 27 03:08 ..
-rw-r--r--   1 root root  99K Apr 26 12:53 config-2.6.32-220.17.1.el6.x86_64
-rw-r--r--   1 root root  99K Feb 10  2012 config-2.6.32-220.7.1.el6.x86_64
-rw-r--r--.  1 root root  99K Nov  9  2011 config-2.6.32-220.el6.x86_64
drwxr-xr-x.  3 root root 1.0K Mar 29  2012 efi
drwxr-xr-x.  2 root root 1.0K Jun 10 07:53 grub
-rw-r--r--   1 root root  15M Jun 10 07:53 initramfs-2.6.32-220.17.1.el6.x86_64.img
-rw-r--r--   1 root root  15M Mar 29  2012 initramfs-2.6.32-220.7.1.el6.x86_64.img
-rw-r--r--.  1 root root  15M Mar 29  2012 initramfs-2.6.32-220.el6.x86_64.img
-rw-------   1 root root 3.4M Jun 10 08:06 initrd-2.6.32-220.17.1.el6.x86_64kdump.img
-rw-------   1 root root 3.5M Jun 10 07:53 initrd-2.6.32-220.7.1.el6.x86_64kdump.img
-rw-------   1 root root 3.4M Mar 29  2012 initrd-2.6.32-220.el6.x86_64kdump.img
drwx------.  2 root root  12K Mar 29  2012 lost+found
-rw-r--r--   1 root root 168K Apr 26 12:55 symvers-2.6.32-220.17.1.el6.x86_64.gz
-rw-r--r--   1 root root 168K Feb 10  2012 symvers-2.6.32-220.7.1.el6.x86_64.gz
-rw-r--r--.  1 root root 168K Nov  9  2011 symvers-2.6.32-220.el6.x86_64.gz
-rw-r--r--   1 root root 2.3M Apr 26 12:53 System.map-2.6.32-220.17.1.el6.x86_64
-rw-r--r--   1 root root 2.3M Feb 10  2012 System.map-2.6.32-220.7.1.el6.x86_64
-rw-r--r--.  1 root root 2.3M Nov  9  2011 System.map-2.6.32-220.el6.x86_64
-rwxr-xr-x   1 root root 3.8M Apr 26 12:53 vmlinuz-2.6.32-220.17.1.el6.x86_64
-rw-r--r--   1 root root  171 Apr 26 12:53 .vmlinuz-2.6.32-220.17.1.el6.x86_64.hmac
-rwxr-xr-x   1 root root 3.8M Feb 10  2012 vmlinuz-2.6.32-220.7.1.el6.x86_64
-rw-r--r--   1 root root  170 Feb 10  2012 .vmlinuz-2.6.32-220.7.1.el6.x86_64.hmac
-rwxr-xr-x.  1 root root 3.8M Nov  9  2011 vmlinuz-2.6.32-220.el6.x86_64
-rw-r--r--.  1 root root  166 Nov  9  2011 .vmlinuz-2.6.32-220.el6.x86_64.hmac

here is the disk usage on boot

# du -h
13K ./lost+found
282K    ./grub
247K    ./efi/EFI/redhat
249K    ./efi/EFI
251K    ./efi
75M .

Problem is that when I got this severer at my ISP I used their default image for RHEL 6 which only allocates 100MB for /boot clearly this is not enough. How can I get around this problem, is it safe to delete any of the above files some of them seem to be on the disk more than once? Is there some way of expand /boot without re-imaging the machine?

ams
  • 285
  • 1
  • 2
  • 6

3 Answers3

29

As per the recommendation of MadHatter here. I will post my answer here as an addendum to the answers here so that it may be used in conjunction with the answers suggested here.

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.

Note that the above command only cleans up existing packages so editing your yum.conf is necessary if you don't want to start accumulating kernel packages again.

Jason Zhu
  • 821
  • 7
  • 10
  • Agreed, best solution, and `package-cleanup` prompts you as to what it will remove before doing so – sMyles Sep 28 '16 at 19:19
16

Following command will remove ALL kernel versions, except for the one that you're currently running:

sudo yum remove `rpm -q kernel | grep -v 'uname -r'`

and for going forward, per ⁠7.4. Configuring Yum and Yum Repositories:

⁠installonly_limit=value

…where value is an integer representing the maximum number of versions that can be installed simultaneously for any single package listed in the installonlypkgs directive. The defaults for the installonlypkgs directive include several different kernel packages, so be aware that changing the value of installonly_limit will also affect the maximum number of installed versions of any single kernel package. The default value listed in /etc/yum.conf is installonly_limit=3, and it is not recommended to decrease this value, particularly below 2.

alexus
  • 12,342
  • 27
  • 115
  • 173
  • 4
    Maybe leave one version prior just to have a backup... – EasyEcho Oct 16 '12 at 20:36
  • 1
    Could you also do this: ```rpm -qa | grep -v `uname -r` | grep kernel-``` to get the list of Kernels that aren't being used? – FilBot3 Mar 12 '15 at 19:01
  • A better solution than @Pred listed is to use package-cleanup. See this answer for how: http://serverfault.com/a/562201/98791 – a coder Apr 04 '16 at 17:30
  • Doesn't that command also remove the current kernel (because the uname -r is surrounded by ' instead of `) ? – bye May 26 '17 at 14:12
8

Delete at least one of the old kernels, as alexus said.

Then:

Edit /etc/yum.conf and specify the limit of the number of kernel versions to keep. It's set to 5 by default, but your system seems to be capable of handling only two:

installonly_limit=2

Finally, complain to the VPS provider about the strange template. /boot is 500MB by default in a CentOS 6 installation.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940