Running out of inodes on Ubuntu
So you’re seeing errors on Ubuntu indicating you’re low on disc space. First step of course is to see if the disc is actually full with df
you should see something like this:
Filesystem 1K-blocks Used Available Use% Mounted onudev 497828 0 497828 0% /devtmpfs 101424 4324 97100 5% /run/dev/xvda1 8117828 2280780 5401772 30% /
Check out the Use%
column, if you see 100% anywhere in that column then that disc is simply full and you need to delete some files.
If you don’t see 100% then there must be another reason for the out of disc space errors. Let’s check the inodes with df -i
the output will be similar to the previous example but this time we’re seeing inode usage. 100% inode usage can cause disc space errors even if the file system is far from full.
Here is a command to find the probblem:
sudo find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n
If you see 100% inode usage then that’s likely the problem. A really common thing on Ubuntu is old kernel header files eating up inodes to the point where the system reaches it’s limit.
Let’s see how many kernel versions we have headers for:
for i in /usr/src/*; do echo $i; find $i |wc -l; done
It’s fine if there are two or three versions listed but if you’re seeing 10 or more versions this is quite likely the problem. Here’s how we can remove old kernel headers:
sudo apt-get -f install
sudo apt autoremove
If either command fails with a disc space error you may need to manually delete a couple of the oldest header file directories that were listed initially.
Now run the previous command again to list header files, this time you should only see one or two versions.