How to determine the inode count
This article explains what an inode count is, how to determine it for your account, and how to reduce it if necessary.
What is the inode count?
An inode is simply an internal data structure that Linux uses to store information about a filesystem object. The inode count equals the total number of files and directories in a user account or on a disk. Each file or directory adds 1 to the inode count.
To maintain the reliability and performance of A2 Hosting servers for all users, there are inode limits in place for shared hosting accounts. If the inode count for your account reaches this limit, you must decrease the count by removing some files or directories.
Here are some reasons why A2 Hosting limits inode counts on shared hosting accounts:
- High inode counts on a server can cause excessive downtime during filesystem checks, because the system has to check every single inode. For example, if a customer account were to have a million cache files, a filesystem check could take hours and impact availability for all customers on the server.
- A large number of files slows down backups and restores considerably. In the event of disaster recovery, it can take much longer to recover if a lot of files need to be restored. For example, it is much slower to restore many small files than a few larger files.
Determining the inode count
The method you should use to determine the inode count depends on the type of hosting package that you have:
- If you have a shared hosting or reseller hosting package, you can use cPanel or the command line to determine the current inode usage for your account.
- For all other types of hosting packages (including managed VPS, managed Flex Dedicated server, and all semi-managed packages), you must use the command line to determine current inode usage.
Method #1: Use cPanel
To determine the current inode count using cPanel, follow these steps:
- Log in to cPanel.
If you do not know how to log in to your cPanel account, please see this article
- In the Stats column of the cPanel home screen, locate the File Usage row. The first number indicates how many inodes your account is using, and the second number indicates the maximum number of inodes allowed for your account. For example, the following image shows an account that is using 96,769 inodes out of a maximum of 300,000 allowed:
Method #2: Use the command line
To determine the current inode count for directories in your account using the command line, follow these steps:
- Log in to your account using SSH.
- To make sure you are in your home directory, type the following command:
To determine the total inode count for your account, type the following command:
find . | wc -l
If you have a large number of files and directories in your account, this command may take some time to complete.
To view a breakdown of inode usage for all directories located in the current directory, type the following command:
find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn
While the command in step 3 displays the total inode usage for your account, this command displays which directories are using the most inodes. The output is sorted, with the most inode usage at the top, and the least inode usage at the bottom.
To view the inode usage for a particular subdirectory, change to the directory (for example, type cd public_html), and then rerun this command. You can progressively step into subdirectories, run this command, and determine where exactly your account is using the most inodes.
Reducing the inode count
If the inode count for your account is too high, you should try to determine the cause as soon as possible so you can bring it back down to an acceptable level. Some common causes of high inode usage are:
- Cron jobs or other automated processes: Automated processes, such as cron jobs, can create a large number of files very quickly. Either modify or disable the cron job, or delete the unwanted files.
- E-mail messages: Old messages in the Trash and Sent folders of users' mailboxes often accumulate. You can download these messages to your local computer (if you want to save them), and then delete them on the server.
If your web site's storage needs are increasing, please contact our sales department at http://my.a2hosting.com
to discuss upgrade options. Common upgrades for shared hosting accounts are a managed VPS or a dedicated server. These packages offer dedicated resources that can streamline your site's performance. They also include full management and the cPanel control panel.