How to Solve Ubuntu Server /boot full Issue Tips, Tricks and Tutorials 19 FEB 2016

If you manage an older Ubuntu server and do a lot of updates/upgrades, inevitably you’ll hit the annoying /boot full issue, which is essentially what happens when the ridiculously tiny /boot folder gets filled up with older kernel version as a result of all your upgrading.

To spot if this is in fact what currently plagues you, simply run the following command to get a quick snapshot of disk space usage:

sudo df -h

If your /boot directory is indeed full or close to 100%, you can run the following command that automatically locates and removes older kernels and headers from the system:

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

With those gone, you can now clean up a bit further by removing packages that aren’t necessarily needed any more (because they were automatically installed to satisfy dependencies for the newly removed packages):

sudo apt-get autoremove
sudo apt-get --purge remove && sudo apt-get autoclean

This should solve your issue.

cat using laptop

Note: If you can’t use apt-get at all because of this problem, you can try to manually delete the kernels yourself. Run the following to get an idea of what can be removed:

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')"

With that list now in your possession, craft a remove operation using those version numbers listed above, followed by an attempt to solve the new dependency issue with apt-get e.g.

sudo rm -rf /boot/*-3.2.0-{101,102,103}-*
sudo apt-get -f install

(As always though, tread with care though when it comes to messing with this part of your server install…)

Related Posts:

About Craig Lotter

Software developer, husband and dad to two little girls. Writer behind An Exploring South African. I don't have time for myself any more.