Published on: February 28, 2017 by Manu M.
This is my first post of the year and covers on how to get the count of inode in your server/account. Before going on further, let me describe what inode is.
inode is a data structure used to represent a filesystem object, which stores the attributes and disk block location(s) of the file system object’s data. Got it? Well, all you need to know (for now) is that a Linux file is “stored” in two different parts of the disk – the data blocks and the inodes. The data blocks contain the “contents” of the file. The information about the file is stored in the inode.
So, why this Blog?
Do you have a hosting account? Does your hosting provide you and unlimited disk space? Usually, any web-hosting company will provide you hosting accounts with a good amount of disk space. However, there will be a certain limit in the inode usage for each account they provide. In many cases, the issue with the account is over usage of inode. So this kb helps you to find the inode usage in a user account.
Finding inode usage
Just login to your account via SSH and run following command from there
find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn
Here is more about the command, just in case if you are curious 🙂
find . – for doing the search in current directory (. can be replaced by full path)
-printf “%h\n” – prints leading directories of file’s name.
cut -d/ -f-2 – trimming the output with de-limiter “/”
sort | uniq -c – sort and count
Sample output would look like this.
manu@sage17:~$ pwd /home/manu manu@sage17:~$ find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn 26126 ./.cache 9873 ./.config 7387 ./Downloads 3142 ./.tor-browser-en 1452 ./Pictures 540 ./.local 402 ./.thunderbird 338 ./Desktop 323 ./.mozilla 139 . 74 ./firefox 62 ./.gconf 50 ./.compiz-1 48 ./.pulse 41 ./.fontconfig
How to read the output
As you can see the first column is the inode count and the second column is the directory. So with this, you can find the directory which uses up high inode and advice customer accordingly.
So if your hosting company has promised an unlimited storage, don’t forget to ask them about your inode limit and make sure you are within the limits always
Category : Howtos, Linux, Troubleshooting