Not enough drive space!

Context; Ubuntu 12.04 server, where root (“/”) has just 7 GB of space (don’t ask me why I was such a Scrooge when I set it up).

For the last two months, I haven’t been able to run updates on the server as it complained of not having enough drive space. On checking, I indeed had only about 20 MB left. I clean away another 500 MB, but alas, the problem persisted. At the time, I neither had the time to investigate or could afford the server going down (as it was integral to my development process), so I left it until tonight.

“df -h” again showed me that I had the 500 MB free, and so I searched online. I found a post that reminded me that there was also a possibility that I’d run out of INodes, and so I checked using “df -i”. True to form, this was the case. I closed down all my mounts and searched for where they were being used using;

find / -xdev -printf ‘%h\n’ | sort | uniq -c | sort -k 1 -n

And to my horror I then noticed 20 kernel versions just sitting there taking up 30% of the INodes. I tried to purge them, but my package manager was wanting to perform another task first that required INodes – Catch 22.

In the end, I moved the files over to the storage drives I had attached and linked them over (in case they were a dependency in some way or another). 30 minutes later of updating and purging, everything was fixed.