Generate an inode report (file count) for Debian, CentOS, cPanel, RHEL, with INODES shell/bash script
If you have every used shared hosting, or are involved with the hosting business in any way, you should already know what an inode is. Each time a file is created, uploaded, and so on, an inode is created. This inode stores information like ownership, permissions, etc … basically all the metadata about the file. What is the purpose of limiting the amount of files/inodes? Because each shared host will have many customers on the same server, customers that have excessive amounts of inodes (anywhere from 100,000 to 500,000 and up), can cause a heavy load on the server during backups, general operation, and can be taxing on hard drives. Most of the time excessive amounts of inodes is due to cache scripts installed by the user, catchall email accounts, and normally the customer/user doesn’t even know they exist. Well fear no more, I have created a shell/bash script that will help generate reports, and soon notify you about inode usage…
Github Repository
https://github.com/tripflex/inodes
Tree display will allow you show sub-directories in the output that have over a specific number of inodes. So if you want a directory with over 50,000 inodes to display the sub-directories in a tree format, use the -t argument.
Exclude will allow you to exclude directories that are below a specific amount of inodes, therefore creating a smaller output/report.
Installation
1 2 |
wget -O ~/bin/inodes https://raw.smyl.es/inodes/master/inodes chmod +x ~/bin/inodes |
Usage
Directory path is not required. If nothing is provided the present working directory is used.
Argument | Example | Description |
---|---|---|
-d | inodes -d /path/to/dir | Specify path to directory to scan. Optional, will use pwd if not specified. |
-t | inodes -t 50000 | Display tree output for directories with over 50,000 inodes. Optional. |
-e | inodes -e 100 | Exclude directories that are below 100 inodes. Optional |
Examples
Output inode report for /my/dir showing tree output for sub-directories on directories over 50000 inodes
1 |
inodes -d /my/dir -t 50000 |
Output inode report for /my/dir showing tree output for sub-directories on directories over 50000 inodes, excluding directories with under 10,000 inodes.
1 |
inodes -d /my/dir -t 50000 -e 10000 |
Output inode report for present working directory without any exclusion or tree output
1 |
inodes |
Troubleshooting
If you get a “inodes: command not found” you need to set the correct path. In installation above we installed into ~/bin/inodes
Check path with this command and make sure the file is in one of those directories:
1 |
echo ${PATH} |
If not you can export path to your .bashrc file
1 2 |
PATH=~/bin:"${PATH}" export PATH |
And verify
1 |
which inodes |
-
Vincent Woo