What are inodes, and what to do if they are over

At any time when using the hosting, you can receive a message that the limit on the number of files expires. First, you check the amount of free disk space and it turns out that it is enough. So what’s the matter? The reason, oddly enough, is inode. In this article, you will learn what they are, what they were created for, and what to do in the situation from which we began our story.

What is an inode?

An inode (short for “index node”) is a data structure that stores information about file system objects, such as files, directories, and so on. It can be compared to a catalog in a huge library, which connects the title and author of the book with their location (room, section, shelf). In other words, inodes are metadata information.

Inodes store information about the owner, information about what rights are granted to a particular file, information about its size, and the like. For each element of the file system, there is an inode, which stores its metadata in tabular structures.

Information contained in inode:

  • file size;
  • the device on which the file is stored;
  • user and group IDs associated with the file;
  • permissions required to access the file;
  • creation, reading, and writing timestamps;
  • data location (but not file path).

 It is important to note that inodes do not depend on the file name. This means that you can copy one file, rename it, and it will still point to the same thing as the original.

How does it work?

Each time a new file is created, it is given an inode number and name, after which it is saved as a unique directory note. Here it is important to remember that one way to run out of free space on the file system is to use all the inodes. This means that even if you have free disk space, you still can’t create a new file. When all Inodes on your system are used, it can cause the system to shut down suddenly.

Commands that are useful

To get basic inode usage data, including the filesystem where inodes are stored, their total number, how many inodes are in use (in number and %), and how many are left, use the df -i command. 

[bluematador   ~]$ df  -i  /dev/bluem1Filesystem   Inodes  IUsed  IFree IUse% Mounted on/dev/bluem1    654972   516   654456   1% /boot 

You can use the -inum command to search for files associated with a particular inode. Conversely, to get the inode file number, use the ls -i command.

ls -i Command: display inode$ls  -i /dir/bluem_article129792 /dir/bluem_article129792 is the inode of /dir/bluem_article.

What can happen to inodes?

The number of inodes on the disk is static. This means that if you have too many files, inodes can run out before the disk space runs out. Once the file system is finished, all new files and folders will be rejected. Until then, there will be no negative consequences. When 100% inodes are used, you will start to notice:

  • Data loss;
  • Application crashes;
  • Restart the OS;
  • Refusal to restart processes;
  • Periodic tasks will not be performed

If you notice any of the above, use df -i to confirm that you have reached the inode limit.

How to reduce the use of inodes?

There are two types of inode quotas: soft and hard. If you exceed the soft quota, you can still create files. If you exceed the hard – you can not.

Many features of your hosting account require the creation of files. If you exceed the hard limit, you will not be able to add new web pages, receive e-mails, install software and perform many other common tasks.

It is best to reduce the use of inode by deleting files long before you reach the hard limit. You can delete files by:

  • Delete unused files from your hard drive, for example, using cPanel File Manager.
  • Delete or archive email;
  • Delete old backups;
  • Clear caches of the content management system and the webserver. Many small files are usually created in caches.

Conclusion

Should you worry about your hoster’s inode limits? If you are a newbie who has just launched your site, inode restrictions are not something you should worry about. It is unlikely that your sites will contain as many files as you can exceed the limit.

Experienced users with large sites or those who plan to host multiple sites in one hosting company must take into account the limitations of the inode. Use the tips in this article, and keep in mind that you can ask Hostpro technical support at any time of the day to provide information on the use of inodes. We will also be happy to help you if you run the risk of exceeding the limit.