After using Ubuntu 14.04 for a little while I got a worrying message from the Software Updater saying “Not enough disk space. The upgrade needs a total of x M free on disk ‘/boot’. Please free at least an additional xxx k of disk space on ‘/boot’. Empty your trash and remove temporary packages of former installations using ‘sudo apt-get clean’.”
Ubuntu /boot Partition Cleanup
When I had installed Ubuntu I had gone with the default suggested partition sizes so it was worrying that so early on I was getting this error. The default for /boot
was 250MB and I couldn’t change it after the fact. I ran sudo apt-get clean
as recommended and although it freed up some space it wasn’t enough.
The Internet’s a Scary Place!
Being new to Linux I did some searching and there was a lot of technical information and scary looking solutions! Not being au fait with Linux nor the shell, this was worrying. I was very surprised that this was even an issue. Why would Ubuntu suggest such a small /boot
partition if it filled up after a couple of months? Why was it so hard to get a simple explanation of the problem? Why no easy fix?
Finally a Solution
After much searching I found Julian Highman’s blog, which clearly explained the issue and offered the most easy-to-understand solution. The Software Updater error message means that there are too many old kernels on the boot partition, which fills up quickly at the default size.
To remove old kernels from the system, run the following shell command:
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge |
This command gets a list of installed kernels, filters out the one you’re currently running, and then passes the rest of the list to apt-get for removal.
After running that your updates should work again. You will need to run this command periodically because old kernels start to accumulate again.
Bigger /boot
The next time I installed Ubuntu I opted for a much larger /boot
partition in order to avoid this issue.