Tsohost Help Centre

Table of Contents

Find inode usage

Updated Jun 8th at 15:12 BST

Disk space issues can be caused by large files or too many inodes. Inodes store information about files and directories (folders), such as file ownership, access mode (read, write, execute permissions), and file type. The maximum number of inodes, like disk space, is set when the server is created.

Symptoms:

Some symptoms of too many inodes will be the same as disk space issues.

You may receive emails from Plesk or WHM that inode limits are being approached or have been exceeded.

You may receive error messages like Out of disk space. Unable to write content to file or failed: No space left on device.

You may receive these errors when, in fact, there is plenty of physical disk space available.

The server may hang or take a long time to respond when attempting to view the contents of a directory.

Warning: This article is intended for advanced SSH users. If you don't know the purpose of a file or folder, don't remove it. Removing system files or directories is irreversible and may break the server (taking all of the sites down).

Switch to the root user.

For an overview of disk usage on the server, use the "df" command.

           [root@server[~]: df
           Filesystem       1K-blocks    Used   Available  Use%  Mounted on
            /dev/ploop29904p1 125684164 11693260 107699656  10%   /
            devtmpfs           524288     60  524228    1% /dev
            tmpfs              524288      1  524287    1% /dev/shm
            tmpfs              524288    311  523977    1% /run
            tmpfs              524288     10  524278    1% /sys/fs/cgroup
            tmpfs              524288      1  524287    1% /run/user/1000

If you have exhausted the inodes within your main file system, it may look similar to the example below:

          [root@server[~]: df -i
          Filesystem         Inodes   IUsed   IFree IUse% Mounted on
          /dev/ploop29904p1 7864320 7864222      82  100% /
          devtmpfs           524288      60  524228    1% /dev
          tmpfs              524288       1  524287    1% /dev/shm
          tmpfs              524288     311  523977    1% /run
          tmpfs              524288      10  524278    1% /sys/fs/cgroup
          tmpfs              524288       1  524287    1% /run/user/1000

To view the inode distribution within the current working directory:

        find * -maxdepth 0 -type d -exec sh -c "echo -n {} ' ' ; ls -lR {} | wc -l" \;

So, if you switched to the root directory of the server and ran the command, it would produce output that looks like this:

            [root@server[~]: cd /
            root@server[/]: find * -maxdepth 0 -type d -exec sh -c "echo -n {} ' ' ; ls -lR {} | wc -l" \;
            backup  2
            boot  7
            dev  78
            etc  7769
            home  1448
            lost+found  2
            media  2
            mnt  2
            opt  11749
            proc  21481
            root  56
            run  393
            srv  2
            sys  1643
            tmp  11
            usr  231243
            var  7468179

In the example, you can see that the var directory contains the bulk of the inodes. For more specifics, move into /var and run the command again.

Note: It is important to drill down enough in the filesystem to separate what can be removed (like cache files) from what can't be removed (like your email content).

          [root@server[/]: cd /var
          root@server[/var]: find * -maxdepth 0 -type d -exec sh -c "echo -n {} ' ' ; ls -lR {} | wc -l" \;
          adm  2
          cache  779
          cpanel  13698
          db  20
          empty  6
          games  2
          gopher  2
          installatron  48856
          kerberos  10
          lib  13004
          local  2
          log  419
          named  49
          nis  2
          opt  2
          preserve  2
          spool  7391257
          tmp  29
          www  18
          yp  2

In the example above, you can see that the /var/spool directory is where the bulk of the inodes are being used. We know this is where the email queue is located on a WHM/cPanel server, so we can come to the conclusion that we have an issue with excessive email messages that need to be addressed.

Not out of inodes?

Too many inodes in a single folder can cause performance issues, even if inodes aren't exhausted on the server. This may be more noticeable if you have several directories with more than 1,024 inodes.

To scan all of the directories on the server, and list the 20 directories with the largest amount of inodes, you can use this command:

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

The output of the command will look like this:

                [root@server ~]# find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n | tail -20
                  2180 /home/onecool/public_html/wp-content/uploads/2018/05
                  2180 /home/onecool/public_html/wp-content/uploads/2019/07
                  2271 /home/onecool/public_html/wp-content/uploads/2019/05
                  2683 /home/onecool/public_html/wp-content/uploads/2020/11
                  2768 /home/onecool/public_html/wp-content/uploads/2020/09
                  2822 /home/onecool/public_html/wp-content/uploads/2019/12
                  2929 /home/onecool/public_html/wp-content/uploads/2020/06
                  3064 /home/onecool/public_html/wp-content/uploads/2020/04
                  3100 /home/onecool/public_html/wp-content/uploads/2020/07
                  3186 /home/onecool/public_html/wp-content/uploads/2020/08
                  3332 /home/onecool/public_html/wp-content/uploads/2020/01
                  3354 /home/onecool/public_html/wp-content/uploads/2019/11
                  3445 /home/onecool/public_html/wp-content/uploads/2020/02
                  3706 /home/onecool/public_html/wp-content/uploads/2019/09
                  3743 /home/onecool/public_html/wp-content/uploads/2020/03
                  3846 /opt/cpanel/ea-openssl11/share/doc/openssl/html/man3
                  3846 /opt/cpanel/ea-openssl11/share/man/man3
                  3964 /home/onecool/public_html/wp-content/uploads/2019/08
                  4845 /home/onecool/public_html/wp-content/uploads/2020/05
                  5078 /home/onecool/public_html/wp-content/uploads/2020/10

Once you have identified where the use is, you can remove content and work to prevent the issue from happening again.