Ubuntu 22.04.1 and Also How I Solved the F*****g /Boot Space Issue

Canonical have today released Ubuntu 22.04.1 and by extension opened direct upgrades for installs running 20.04.

I was very excited to upgrade today with my StarBook Mk V but I came across an issue that’s plagued me for some time not just with distribution upgrades but occasionally with routine updates.

Situation: when you run updates/upgrades you get something along the lines of this:

The upgrade needs a total of X M free space on disk '/boot'. Please free at least an additional Y M of disk space on '/boot'. You can remove old kernels using 'sudo apt autoremove', and you could also set COMPRESS=xz in /etc/initramfs-tools/initramfs.conf to reduce the size of your initramfs.

Running sudo apt autoremove doesn’t resolve the problem and as a Linux novice I cannot speak about compressing initramfs & the implications there.

Apparently this is caused by a load of kernels the system “hangs onto” following an upgrade filling up the /boot partition. I *think* this is fixed /better handled in versions after 20.04 but I’m not so sure. Indeed it’s a very bizzare problem because surely Ubuntu ought to handle this itself right?

Today I found out how to deal with it and I decided to share it with the internet. Disclaimer: I’m currently learning Linux and Ubuntu. This may kill your system. If it does I apologise but only slightly.

First thing’s first: list the current kernel that’s currently in use. We’re going to try really hard not to delete it.

uname -r

Once you’ve made a note of that then list out the kernels that have been installed:

dpkg -l | grep linux-image

In my case there were about 7-8 listed (!!!) in addition to the currently running kernel. What we need to do is trim this list down so that we’ve got some space in the /boot partition.

At this point you should’ve got a backup and possibly consulted someone who’s a Linux expert as opposed to a Microsoft one.

Remove excess kernels by running the following command depending on what you find (replacing the version numbers of course):

sudo apt-get purge linux-image-5.xx.x-xx-generic
sudo apt-get purge linux-image-unsigned-5.xx.x-xx-generic

You should probably keep the immediate past version to the one identified with uname -r.

This should free up enough disk space in /boot so that you can upgrade your OS however you may run into the problem I had and this is the one that’s bugged me for ages: if you remove the signed image for whatever reason apt installs the corresponding unsigned image. Not knocking a free offer but I’m not sure why that is. So anyway the trick is to purge both signed and unsigned at the same time like so:

sudo apt-get purge linux-image-5.13.0-44-generic linux-image-unsigned-5.13.0-44-generic

Once you’ve got the list down to about 2 kernels you should be able to update.

I’m so far enjoying Jammy Jellyfish and it was good fun finally cracking the excess kernel problem at the same time.