ლ(ಠ益ಠლ)

Ubuntu: No Space Remaining on Boot Partition

The following is an outline of a process for handling initramfs build failures due to low free space on the /boot partition.

Specifically, this is relevant for Ubuntu systems administrators whom may find themselves unable to use the popular ‘apt-get’ to remove older kernels, in the event new kernel package(s) were pulled in, installation attempted, and then subsequently halted due to low disk space on the partition.

This is a unique chick and egg scenario I have observed on more than one occassion due to overly conservative storage allocations for the boot partition.

"gzip: stdout: No space left on device"

When ‘apt-get’ is invoked, you will observe likely something close to the following:

1
2
3
4
gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-<version>-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1

Check which kernel you’re currently using:

1
$ uname -r

Remove old files relative to the kernels no longer needed.

Warning: Do not remove files pertaining to the kernel the system is currently running–you may want to fall back to them in an emergency.

1
2
3
4
5
$ rm /boot/abi-<version>-generic
$ rm /boot/config-<version>-generic
$ rm /boot/initrd.img-<version>-generic
$ rm /boot/System.map-<version>-generic
$ rm /boot/vmlinuz-<version>-generic
1
$ apt-get dist-upgrade

Any invokation of the package manager, for instance ‘apt-get dist-upgrade’, should identify that the kernel you are trying to install is in a half-configured state, and invoke the update-initramfs script to kick-off generating a new initramfs image. This will be followed by an update to the bootloader configuration.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ apt-get dist-upgrade
Setting up linux-image-3.13.0-77-generic (3.13.0-77.121~precise1) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-3.13.0-77-generic
vmlinuz(/boot/vmlinuz-3.13.0-77-generic) points to /boot/vmlinuz-3.13.0-77-generic
 (/boot/vmlinuz-3.13.0-77-generic) -- doing nothing at /var/lib/dpkg/info/linux-image-3.13.0-77-generic.postinst line 491.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-77-generic /boot/vmlinuz-3.13.0-77-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-77-generic /boot/vmlinuz-3.13.0-77-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-77-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.13.0-77-generic /boot/vmlinuz-3.13.0-77-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.13.0-77-generic /boot/vmlinuz-3.13.0-77-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.13.0-77-generic
Found initrd image: /boot/initrd.img-3.13.0-77-generic
Found memtest86+ image: /memtest86+.bin
done
Setting up linux-image-generic-lts-trusty (3.13.0.77.69) ...

With disk space freed up on /boot by deleting old kernels no longer needed, the above operation will complete sucessfully.

Clean Up

The deleting of files tied to previously installed kernel packages–files which are supposed to be maintained by the package manager, is naturally, not a recommended practice.

Therefore, it is wise to let dpkg formally know that packages are no longer needed.

Perform the following to locate kernel-related packages. I find the presentation of ‘dpkg -l’ in conjunction with some grep-ing to be much better than “dpkg –get-selections”:

1
2
3
4
5
6
7
8
9
10
$ dpkg -l 'linux-*' | egrep -v "un" | egrep -i "name|status|=|image|headers|ii"
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                              Version                           Description
+++-=================================-=================================-==========================================================================
ii  linux-firmware                    1.79.18                           Firmware for Linux kernel drivers
ii  linux-image-3.13.0-77-generic     3.13.0-77.121~precise1            Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-generic-lts-trusty    3.13.0.77.69                      Generic Linux kernel image
ii  linux-libc-dev                    3.2.0-98.138                      Linux Kernel Headers for development

Purge:

1
$ apt-get purge linux-image-<version>-generic

If you are the cautious type:

1
$ update-grub && update-initramfs -u

This is rather unnecessary (see the above terminal data), but they aren’t your electrons, right?

Comments