Clean Up a Full Ubuntu ‘/boot’ Partition

If the /boot partition fills to 100% you’ll likely find yourself stuck in a loop. In order to remove old Linux kernels and free space you will likely first need to install dependencies, but to install those dependencies you require free space in the /boot partition. To break out of this bad recursion joke, old kernels will need to be forcefully removed.

Everything here will require root permissions. Either launch a root shell now or prepend sudo to each command

sudo -i

First up, let’s see which kernel is running

uname -r

Take note of this. Do not delete it this kernel.

List installed kernels

dpkg -l | grep linux-image

Delete kernels in bulk, using the minor version number to differentiate between them and save some time. I like to leave ~3 kernels in place in case of emergency

rm -rf /boot/*-4.4.0-{31,34,36,38,42,45,47,51,53,57,59}-*

Resolve dependency issues

apt-get -f install

Clean up old kernel residue

apt-get autoremove

Update grub to reflect the change in available kernels

update-grub

Reboot and continue what you were trying to do

reboot

Leave a Reply

Your email address will not be published. Required fields are marked *