Search This Blog

Sunday, October 16, 2016

Making space on boot for Ubuntu

Often we need to create space on the Ubuntu's boot partition. The offending files are older versions of Ubuntu, still sitting on the boot partition. Deleting old versions of Ubuntu is straightforward. Simply, run the following command and boot drive will be cleaned of the old versions.

sudo apt-get autoremove --purge

The above command will delete all, but the current and previous version in the boot partition, allowing you to load new updates of the OS.

However, sometimes deleting the old updates through the previous command is not enough. I ran across this myself when my software updater claimed that I needed to free up still more space. I found the following command on a blog that cleans out all but the current version. Use this only when the previous command is not adequate for your task..

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 did the trick for me, and I was able to install the latest updates.


All the best!

No comments: