How to check Inode usage of a cPanel account

Command to check Inode usage of a Directory/cPanel account

 

“df -h” command will display disk usage and “df -i” will show the total inode usage on the server. Each file on a Linux server has got an unique identification number called inode number. On a linux server every file and directory have a unique inode number.

Type the below command to see the inode number of a file. In the below example inode number of error_log file is 168693.

Syntax : ls -i

root@server [~]# ls -i error_log
168693 error_log

“df -i” command will show the total inode usage of the server. An example is given below :
 

root@server [~]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda3 14868480 1657227 13211253 12% /

 
Inode usage on the above Linux Server is 12%. On some servers the inode usage might reach 100% full like shown below:
 

root@server [~]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sdc1 94465477 94465470 7 100% /

 
All the services on the server will be down when the inode usage reaches 100%. On the above server you should check which directory is using high inode.
Type the below command to check inode usage per directory. The below command will show which cPanel user is using high inode

COMMAND : echo “Inode usage for: $(pwd)” ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf “$c\t\t- $d\n” ; done ; printf “Total: \t\t$(find $(pwd) | wc -l)\n”
 

root@server [~]# cd /home

root@server [/home]# echo “Inode usage for: $(pwd)” ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf “$c\t\t- $d\n” ; done ; printf “Total: \t\t$(find $(pwd) | wc -l)\n”
Inode usage for: /home
86565478 – samaccount

Some directory under user ‘samaccount’ is using high inode. Change directory to ‘samaccount’.

root@server [/home]# cd samaccount

Run the above command again to check what is using high inode under user “samaccount”

root@server [/home/samaccount]# echo “Inode usage for: $(pwd)” ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf “$c\t\t- $d\n” ; done ; printf “Total: \t\t$(find $(pwd) | wc -l)\n”
Inode usage for: home/samaccount

74545918 – mail

 
From the above example you can see that “mail” directory under the cPanel account “samaccount” is using high inode. There will be lot of emails in the “mail” directory and that is the reason why inode reached the limit.
Remove the emails in the “mail” directory to free inode usage. On most of the servers “mail” and “cache” directories consume high inode because there will be lot of files in those directories.
 
You can free inode usage only by deleting files in the directory.

How to check inode usage for cPanel accounts

On a cPanel server you can check the inode usage of an account by enabling it in the tweak settings.

1. Login to WHM (Webhost manager) using the root login details

Enter root password of the server to access WHM

2. Search for ‘Tweak Settings’ in the WHM search bar. Click on ‘Tweak Settings’ Under ‘Server Configuration’

Home » Server Configuration » Tweak Settings

3. Click on ‘Display’ tab in tweak settings

4. Change “Display File Usage information in the cPanel stats bar (inode count)” to On. By default it will be off.
 

Enable inode usage in WHM

Enable inode usage in WHM


 
5. Save the tweak settings.

=================
Updating tweak settings…

Your changes have been saved.

Restarting cPanel daemons…done.

Updating your system to reflect any changes…
Updating “Display File Usage information in the cPanel stats bar (inode count)” from “Off” to “On”.
“Display File Usage information in the cPanel stats bar (inode count)” was updated.
Done.
==================

Now login to cPanel and check the inode usage of the account. Check the screenshot below :
 

Inode usage cPanel

Inode usage cPanel