Friday 23 October 2015

Elementary OS and other distributions - ROOT low on space

This morning I again got a warning message the 'root' is low on space.  I've mentioned before that I'm used to the old days when Linux fitted nicely onto a single floppy.  And that a legacy of that is my tendency to only allocate about 15GB to the Linux root file system.

One major problem with root getting low is its impact on /tmp, particularly during operations like working with a HD video or something similar that uses /tmp a lot.  That is easily fixed in the short term by making /tmp a link to a tmp directory in my /home.

But even with that in place, I was warned that I knoy had around 500MB of free space in /root today.  So I set about discovering the culprit.  An analysis of my file scructure soon showed that I had almost 7GB in /usr, with much of it in /share.  One of the  surprising finds was around 2GB of icons that I never use.  Another was a huge stash of old Linux kernels and headers.

By deleting the folders for icons I never use from /usr/share/icons I managed to get about 1GB of free space.  it was after that I discovered all the kernels and headers.  But past experience reminded me that digging around these stripping one at a time was slow and tedious.  However deleting them all in one go is a big risk.

I used the uname -r command in a terminal to show me which kernel is being used, the rebnooted the system to confirm that this was the one used by GRUB.  I am aware of the importance of leaving at least one previous kernel and header in the system as a fallback in case the one being used fails.  In practice however, I have never managed to get a system to boot into one of the old kernels from GRUB.

So I opted for the riskier method of stripping the old kernels by purging all but the one currently in use.

Using the following in a terminal (acquired from:  https://ubuntugenius.wordpress.com/2011/01/08/ubuntu-cleanup-how-to-remove-all-unused-linux-kernel-headers-images-and-modules/)

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

Then waiting while it did its business then rebuilt GRUB brought my total free space on /root  to a little over 4GB.  Plenty to get me out of trouble until I decided some time to repartitions the hard drive and reinstall from scratch.

Before too long Elementary should complete another update with a replacement kernel and I should have a backup kernel and headers in place anyway.

For now, I have some room to move again!




No comments:

Post a Comment