Help Docs Server Administration Linux Server Administration What Is an inode?

What Is an inode?

In Linux, an inode describes a filesystem object like a file or directory, storing attributes and data location. It's akin to a library card, specifying the file's location and unique to each file in a directory.

An inode is a type of data structure on a Linux operating system which describes a filesystem object, such as a file or directory. Each inode stores the attributes and disk block location of the object’s data. These object attributes can include metadata, as well as owner and permission data. Directories are lists of names assigned to inodes. A directory contains an entry for itself, its parent, and each of its children. You can think of an inode being like a library card. The system specifies where on the hard drive the file is stored. Each file in a directory has a unique inode assigned to it.

Is there a limit to the number of inodes per filesystem?

There is an upper limit to the number of inodes that can exist on a filesystem. This isn’t a hard-and-fast number because different factors go into determining the maximum number of inodes available in a directory. Generally, the upper limit will only become an issue during the resize process of increasing the amount of disk space on your server. When you are reaching this limit, a member of our Operations team will contact you and let you know that you’re reaching the maximum number of inodes allowed. If you’ve reached this limit, you are likely experiencing other issues, such as your FTP client timing out.

There are plenty of ways you can configure your files so that you don’t reach the inode limit on your server:

  • Never store all files in a single directory: split your files up into different directories like storing all your images in the /image directory and your HTML in an /html directory.
  • Develop a logical disk structure and spread out the number of files.
  • Use a program that will split uploaded content into directories which reflect the date they were uploaded on.

Things you can do:

As always, our Support team would be glad to assist, but if you are interested in some commands to troubleshoot on your own from the command line, see the examples below.

Example 1:

Am I out of disk space, or have I reached my inode limit?

The two commands used to find the answer are very similar. From the command prompt logged in as the root user, df -h will display your current physical disk usage, whereas df -hi will display your inode utilization. The results of both commands will include a % utilization, so you can quickly find the culprit by looking for the 100% under the Use% for the physical disk usage results, and IUse% for the inode usage.

Example 2:

Do inodes have any other use?

Yes they do! One interesting item about inodes is that each one has a unique inode number. This is very helpful if you find files or folders that are named with special characters that are very hard to reproduce on a keyboard but you need to manipulate them. Since each file, folder and symlink has a unique inode number, you can simply manipulate them by referring to their inode number rather than their name.

Example 3:

Deleting files with the inode number

For example, I created a file named file_with_weird_characters.txt to represent a file that is named with special characters and spaces. It would be very hard to delete the file with the rm command by referring to its name, so instead we’ll use its inode number which we can easily get with the ls -ail command:

Command:

ls -ail file_with_weird_characters.txt

Output:

61741762 -rw-rw-r--. 1 root root 0 Jan 10 15:27 file_with_weird_characters.txt

The result shows us that the inode number of file_with_weird_characters.txt is 61741762.  Now we can easily remove this file by using the find command in conjunction with the rm command:

find . -inum 61741762 -exec rm -i {} ;

The above command will find the file with inode number 61741762 and then the -exec rm portion will remove it.

Was this article helpful?