When updating Ubuntu, old kernel versions are kept in /boot so that if you find that the latest one doesn’t work out, you can just boot into an older one. Unfortunately this also means that eventually your /boot partition will fill up if you never remove old kernels.

I usually have 100MiB /boot partitions on most of my Ubuntu systems so they fill up in a few months. There is plenty of documentation on the web for “/boot full ubuntu” though a while ago I found a script that easily removes all except your latest kernel. Here it is (run as root).

sudo su dpkg --get-selections|grep 'linux-image*'|awk\
'{print $1}'|egrep -v "linux-image-$(uname -r)|linux-image-generic"\
|while read n;do apt-get -y remove $n; done exit

[UPDATE]
You may see one or more of these errors when running the script:

The link /vmlinuz is a damaged link
Removing symbolic link vmlinuz you may need to re-run your boot loader [grub]

The link /initrd.img is a damaged link
Removing symbolic link initrd.img you may need to re-run your boot loader [grub]

If like me your boot loader is grub (shown in the square brackets) then you can fix it by simply running:

sudo update-grub

One thought on “/boot full on Ubuntu”

Leave a Reply

Your email address will not be published.