What is an inode? Its function and use explained

Inodes are a management structure for file systems in unixoide operating systems. In this context, inodes are data headers in inode lists or other similar data sets which contain meta data on saved files. This meta data will contain information such as access rights, save location, groups, user IDs or the time changes were made or the file was accessed.

What is an inode?

Inode is short for “index node”. It is used as a form of file management which has played an important role since the introduction of the Unix operating systems and those based on it such as Linux or macOS. The main function carried out by inodes in file systems is to reference, manage and locate certain files in the system by using unique and unchangeable inode numbers. Being a defined data structure, inodes describe and manage specific files using meta data. The type of file system will determine which meta data is used.

Despite not containing information of the file name themselves, inodes generally include the following information on files and file blocks:

  • Type and access rights
  • Number of hardlinks
  • User ID (UID)
  • Group ID (GID) or GUI
  • Size of the file in bytes
  • Date of the last change (mtime)
  • Date of the last status change (ctime)
  • Date of the last access (atime)
  • Address of data blocks
  • Address of the indirection block
  • Number of links
  • Version number

How do inodes work?

Unix systems don’t manage the sectors of disk partition using clustering, rather they use data blocks. Unlike DOS systems which use FAT tables, inodes are used to manage and reference the directory data. If data is stored on the hard drive in set data blocks, it can quickly lead to the file exceeding the memory of the block. The system then finds another available block in which to save the rest of the file. This is where inodes come into play.

Inodes ensure that data saved in the system can be found using reference and directory data as well as the inodes and the unique inode number. A big advantage here is that they don’t rely on the file name. If a file is copied and renamed, it can still be found again using the same inode number as the original file. This is the case with hardlinks, which are created by users with the Linux in command. This form of internal bookkeeping has the advantage of allowing inodes to go to original files as well as backups without taking up more memory.

Since inodes are set up differently depending on the system, a file may exceed the size of the inodes available. In this case the original inode refers to another inode, sometimes called an indirection block, which contains the rest of the meta data.

Note

Since you set the scope of the inodes from the beginning, the ones available may not be sufficient for a large number or files in certain circumstances. In this case the file system will need to be restructured with a larger number of inodes.

When do you use inodes?

Inodes are used to manage and structure file systems and are used in both private Linux systems as well as managed service solutions. Users and companies looking for cloud solutions for servers with unixoide operating systems can access inode data structures. As with most cloud services and depending on use you could get a public cloud or a private cloud.

Which file systems support inodes?

All unixoide operating systems such as Linux or MacOS use inodes. However, depending on the supported file system, the structure and the makeup of the inodes may change. This is where ext2/ext3/ext4 systems in the form of inode lists or tables are used as descriptive data headers. The inode list is created when the system is set up and cannot be changed subsequently. On top of this ext4 inodes with 256 bytes occupy the hard drive and they can’t be used in any other way. In this data system an inode describes, in each case, a file or a directory in the system using the meta data belonging to them.

Alongside this there are more complex file systems such as xfs or btrfs in which inodes are first created when they are needed to find files. In this case no lists or tables containing inodes are created. Another difference in how they work can be found in disk inodes and inodes which are used to process Linux memory (in-core inodes).

Overview of important inode commands

Since there is a limit of available inodes depending on the file system, you need to know how to display the used inodes or the areas occupied by inodes in the system. This is sometimes required if there are not enough inodes available in the system for other files.

Command to show used areas in the file system

If you want to display which areas are being used by inodes in the file system you can use the following command:

~ find /home /tmp -xdev -printf ´%h \n´ | sort | uniq -c | sort -k 1 -nr | head -n 20
shell

Command to get an overview of current inode use

To see the inodes currently being used in the system, use this command:

df -ih
shell

For an overview of inode use including which file system, the total number of inodes, current use and which inodes are being used, enter this command:

df -i
shell

Command to display specific inode numbers

To display the specific inode number of a file you can use this command:

ls -i
shell

Command to display all files of an inode

If you want to know which files (including originals, copies or backups) are referenced by an inode, use the following:

-inum
shell

Tips if inodes are overloaded

A high load on inodes doesn’t always mean that your memory is running out. Sometimes, increased use of inodes can be accounted for due to excessively small amounts of data such as temporary TMP files, caches or sessions. The problem can usually be solved by automatically deleting all files that are more than 14 days old. To do this you can execute a cron job with the following command:

03 *** /usr/bin/find /path/to/files/* -type f – mtime +14 -delete > /dev/null 2>&1
shell

What happens if I have too few inodes?

If you don’t have enough inodes for other files, you may start noticing some of the following under certain circumstances:

  • Applications crash
  • Data gets lost
  • Unplanned restarts
  • Processes crash and do not restart
  • Planned processes do not start automatically

If your inode capacity is actually used up, we would recommend you create more free capacity. Alternatively you could undertake the relatively laborious process of restructuring the file system and increase the maximum number of inodes.

Was this article helpful?
We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.
Page top