How to find and clear inodes

H

There comes a time when the control panel or your site in general exhibits a strange behavior claiming “No disk space left” or “Inode count full” while there is plenty of disk space available. This is down to inode usage . Inodes are filesystem structures which describe (among other attributes) a file or a directory. They can be of 1kb (or smaller) and up to 4.7GB (or more depending on the filesystem) which means that an email file or thumbnail can and will take up 1 inode. More info on inodes on the wiki – https://en.wikipedia.org/wiki/Inode . For an average user this might not be an issue but for a large portal or site with thousands of users and their files pilling up slowly over time, it can be a major issue. Luckily, inodes can be found and cleared with some console magic in the form of commands.

1. List inodes

df -i

The output of this command will show the general inode count for your system.

 

Once you got an idea, you can proceed to clearing some.

 

2. Find and sort inodes

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

Of course there are a plethora of commands to use but I prefer this one over the others mainly due to sorting.

The find function in location “/” with xdev and printf arguments + sorting them from low to high.

You can change / with any directory you wish. This makes finding and clearing a whole lot easier.

 

**Take extra care when deleting files.

That’s all for now.
Enjoy some basic filesystem maintenance.

About the author

By mvps

Recent Posts

Archives

Categories