Inodes - indexing the file system
Table of content
Inode (index node) is a basic concept in the Linux/UNIX file system. Each object in the file system is represented by Inode.
Each file in Linux/UNIX environment has the following attributes:
- a: append only (add only)
- c: compressed
- d: no dump
- e: extent format
- i: immutable (not modified)
- j: data journalling (counting data)
- s: secure deletion
- t: no tail-merging
- u: undeletable (can not be deleted)
- A: no atime updates (not updated at any time)
- C: no copy on write
- D: synchronous directory updates (synchronous directory updates)
- S: synchronous updates
- T: top of directory hierarchy
All of the information above is stored in an Inode. To put it briefly, Inode identifies the file's attributes. Each Inode is identified by a unique number within the file system, it's also known as an index number.
Inode is an internal data structure that Linux/UNIX uses to store information about the filesystem objects.
Reasons to Limit the Number of Inodes
To maintain the reliability and performance of shared hosting servers for all users, HostPulse limits the number of Inodes for the different hosting plans.
If the number of Inodes in your account reaches this limit, you should reduce their number by removing unnecessary files and/or directories.
Here are some reasons why HostPulse limits the number of Inodes in shared hosting plans:
The large number of Inodes on the server can cause excessive file system checks as the system checks each individual Inode. For example, if a client account has a million cached files, checking the file system can take hours and cause a big delay for all clients on the server.
The large number of files slows the creation of archives as well as site recovery from archive as several large files recover much faster than a large number of small files.
How to determine the number of Inodes in the hosting?
HostPulse always strives to create additional custom solutions in cPanel to maximize the ease with which users can manage their hosting accounts.
To have easy access to the Inodes statistics of his hosting plan, the user only needs to log in cPanel and open the Inode Resources tool in the Metrics section:
The next screen loads a beautiful animated graphics showing the total number of Inodes used by this hosting plan:
Using SSH commands
To determine the total number of Inodes, enter the following command
find. | wc -l:
cpaneluser@servername [~]# find . | wc -l 88129 cpaneluser@servername [~]#
If you have a large number of files and directories in your account, it will take some time for the command to return the countdown.
To see a breakdown of Inodes used in all directories in the current directory, enter the following command:
find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn
cpaneluser@servername [~]# find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn 66619 ./public_html 7205 ./.opcache 3697 ./tmp 2972 ./.trash 2680 ./mail 2105 ./sites 317 ./ssl 283 ./etc 256 ./.cpanel 173 ./logs 48 . 27 ./.softaculous 14 ./softaculous_backups 9 ./.razor 8 ./.cphorde 7 ./wpbackups 7 ./.gnupg 5 ./.htpasswds 3 ./.spamassassin 3 ./.attracta 1 ./public_ftp 1 ./.subaccounts 1 ./.ssh 1 ./.sqmaildata 1 ./.pki cpaneluser@servername [~]#
While the previous command shows the total use of Inodes in the account, this command shows which directories contains the most Inodes. The result is sorted according to the number of Inodes used - the directories with the highest number of Inodes are at the top of the list, those with least Inodes - at the bottom.
To view Inodes in a particular subdirectory, you must enter it with the
cd command (for example, type
cd public_html) and then execute the two commands described in the examples above.
You can use the
stat command to view Inodes for a particular file:
ladmin@ladmin-VirtualBox:~$ stat 2018-03-03-20939.png File: ‘2018-03-03-120939_1280x919_scrot.png’ Size: 55450 Blocks: 112 IO Block: 4096 regular file Device: 801h/2049d Inode: 526793 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1000/ ladmin) Gid: ( 1000/ ladmin) Access: 2018-04-25 08:33:25.550207845 +0300 Modify: 2018-03-03 12:09:40.373262667 +0200 Change: 2018-03-03 12:09:40.373262667 +0200 Birth: - ladmin@ladmin-VirtualBox:~$
Reduce the number of Inodes
If the number of Inodes in your account is too high, you should try to determine the reason behind this.
Some common reasons for the large number of Inodes are:
Non-precision work of Cron jobs or other automated processes can create a large number of files in a very short time. Modify/deactivate the cron job (if such connection is established) or delete the unnecessary files.
Old messages in user mailboxes are often not deleted from the Trash folder. You can download these messages to your local computer (if you want to save them) and then delete them from the server.
Other folders, where you can look for forgotten files are
/cache - the small file size of these directories usually misleads -
50MB disk space may contain
50 000 text files (Inodes).