Saturday, May 7, 2016

Ubuntu: Root filesystem full? Try deleting old kernel images

I ran out of space on my root-partition today and was stumped for a second.

This command was useful to find out where the space was being used:
cd /
sudo du -sh * .
Then I found out Ubuntu doesn't delete old kernel images (which can take up several GBs over time) automatically, one has to do this manually. Here's how:

First, run these commands to do some maintenance / cleanup:
sudo apt-get autoremove --purge
sudo apt-get autoclean
sudo apt-get clean
There are several ways to find out all installed kernel image versions and delete them, but I chose to go with this one, because it seemed to be the most straight-forward and the least prone to error:

Install "synaptic":
sudo apt-get install synaptic
Find out your current kernel version:
uname -r
This is your current version, which you DO NOT (!) want to uninstall.

Then start Synaptic.

In the "Quick filter", type "linux-image".
That will show a list of all packages which match that name, among which are several named like this: "linux-image-X.XX...". Highlight all the older versions (be careful NOT TO select your currently installed version), then right-click and select "Mark for complete removal". It will ask you if you also want to remove packages associated with these. Yes, you do. Then hit "Apply".

This will take a while, depending on how many old kernels you have installed. On my system, about 8 GB of space was freed after this.

Once that's done, enter "linux-header" in the quick-filter and repeat the procedure. Again, be careful not to remove your current kernel-version. On my system, about 3 GBs of space were freed after this.

Source

No comments:

Post a Comment