I’ve recently been looking at issues regarding separate /boot partitions and people running out of free space. Being a long time user of Ubuntu and LVM, I have a /boot partition that was appropriately sized for kernel of the release I installed (Ubuntu 13.04!), but now that I’m running Artful Aardvark, which will become Ubuntu 17.10, my /boot partition is a bit small.

I don’t have any extraneous files in my /boot partition, like .old-dkms files (being worked in bug 1515513) or old kernels. So I need some solution to make the files that are there take up less space. Fortunately, it is possible to choose the compression method used by update-initramfs when it makes initrd images. The default “COMPRESS=gzip” can be found in /etc/initramfs-tools/initramfs.conf.

Because configuration options are also read from /etc/initramfs-tools/conf.d/ and after the initial initramfs.conf file I decided to create a file named “compressed” in that directory with the contents:

COMPRESS=xz

After which I needed to update the initrd.img files in my /boot partition. I can do this with:

sudo update-initramfs -u -k all

Its easy to confirm the compression method used:

$ file /boot/initrd.img-4.12.0-13-generic
/boot/initrd.img-4.12.0-13-generic: XZ compressed data

Now I’ve managed to create some more free space in my /boot partition, however it may take a bit longer for update-initramfs to run and may increase boot time a little. That sounds better than reinstalling though!

It is also worth noting that a follow on error from update-initramfs failing due to a lack of free space in boot is that it leaves extra files in /var/tmp/. Thanks to the reporter of bug 1713004 for pointing this out.