Skip links

Inodes explained

Inodes are a file data structure that stores information about any Linux file except its name and data. They were adopted into Linux in the 90s—and for good reason. They’re an excellent way to keep track of how your files are stored, and the method many systems are still based on today. Linux filesystems are complicated things to understand, especially when you get down into the weeds of data and metadata. Every time you run the ls command and see the output—files listed, permissions, account ownership, etc.—understand that the data about the files you see is stored somewhere separate from the files themselves, and must be called up. Inodes are behind the scenes working hard, so you don’t have to.

By definition, an inode is an index node. It serves as a unique identifier for a specific piece of metadata on a given filesystem. Each piece of metadata describes what we think of as a file. That’s right, inodes operate on each filesystem, independent of the others. Where this gets confusing is when you realize that each inode is stored in a common table. In short, each filesystem mounted to your computer has its own inodes. An inode number may be used more than once but never by the same filesystem. The filesystem id combines with the inode number to create a unique identification label.

Inode doesn’t contain the file name. Reason for this is to maintain hard-links for the files. When all the other information is separated from the file name then only we can have various file names pointing to the same Inode.

Inode Contents

An Inode is a data structure containing metadata about the files.

Following contents are stored in the Inode from a file:

  • User ID of file
  • Group ID of file
  • Device ID
  • File size
  • Date of creation
  • Permission
  • Owner of the file
  • File protection flag
  • Link counter to determine number of hard links

Example:

 

  1. ls -ld new1

Linux Inodes1

Look at the above snapshot, it shows some of the Inode contents.


Inode Table

The Inode table contains all the Inodes and is created when file system is created. The df -i command can be used to check how many inodes are free and left unused in the filesystem.

Linux Inodes2

Look at the above snapshot, the command “df -i” shows the usage of several file systems.


Inode Number

Each Inode has a unique number and Inode number can be seen with the help of ls -li command.

Linux Inodes3

Look at the above snapshot, Directory Disk1 has the three files and each file has a different Inode number.

table:eq(0) > tbody:eq(0) > tr:eq(0) > td:eq(0) > p:eq(11)” data-section-id=”” data-ap-network=”adpTags” data-render-time=”1686612019330″ data-refresh-time=”1686612019330″ data-timeout=”2219″ style=”color: rgb(51, 51, 51); font-family: inter-regular, system-ui, -apple-system, BlinkMacSystemFont, “Segoe UI”, Roboto, “Helvetica Neue”, Helvetica, Arial, sans-serif; white-space: normal; clear: both; text-align: center; margin: 10px auto 20px; width: 728px; height: 250px; overflow: hidden;”>

How many inodes are there?

If you don’t care for math, you may want to skip this section. There are many inodes on every system, and there are a couple of numbers to be aware of. First up, and less important, the theoretical maximum number of inodes is equal to 2^32 (approximately 4.3 billion inodes). Second, and far more important, is the number of inodes on your system. Generally, the ratio of inodes is 1:16KB of system capacity. Obviously, every system is different, so you need to do that math for yourself.

Advanced usage

There is good news for those of you who are math averse: “There’s a command for that.” To check the number of inodes on your system, you can use the -i option with the df command, as seen here:

[tcarrigan@rhel ~]$ df -i /dev/sda1
Filesystem     Inodes IUsed  IFree IUse% Mounted on
/dev/sda1      524288   312 523976    1% /boot

You can see from the command syntax and the output above that we ran df -i on filesystem /dev/sda1. There are a total of 524,288 inodes on this filesystem, with only 312 of them being used (about 1%).

File-level inode

We can also look at the inode number of a specific file. To do this, we use the ls -i command on the desired file. For example:

[tcarrigan@rhel my_articles]$ ls -i Creating_volume_groups 
1459027 Creating_volume_groups

The inode number for this file is 1459027.

Directory-level inode

Just like with files, we can also see the inode of a directory. To do this, we use the ls -i command again with a few additional options. For example:

[tcarrigan@rhel article_submissions]$ ls -idl my_articles/
352757 drwxrwxr-x. 2 tcarrigan tcarrigan 69 Apr  7 11:31 my_articles/

You can see that we used -i (inodes) as well as -l (long format) and -d(directory). These flags present us with a plethora of information about the my_articles directory, including inode number, permissions, ownership, etc.

 

How to check the number of inodes in your hosting account

An inode is short for index node. In Unix-based file systems, an inode is considered to be a data structure that represents a single file system object. The inode space is used to ‘track’ the files stored on the hard disk. The inode entries store metadata about each file, directory or object, but only points to these structures rather than storing the data. Each entry is 128 bytes in size. In simple words, each inode usually equals one file, folder, email or any other unix object in a file system.  You can normally check the number of inodes in your hosting account by simply going to cpanel, and checking your disk space, as discussed above.   and shown below.


when logged into your cpanel account, you need

To see the general File Usage, move to Stats section on your right:

Exceeding the inodes limit

Once the inodes limit is reached, your account behaves in the same way as when the disk space limit is exceeded. Basically, you won’t be able to create/upload new files, receive emails, write data in the MySQL database, and your cPanel will show errors as no temporary files can be stored on your account anymore. You might also see your website down if the application used is doing continuous queries to the database, storing new data or if it requires to save new data in a temporary folder.

Resolving the issue

The inode usage can also be reduced by removing files and directories from your account. Our Support Team can provide a breakdown of your inode usage as per folders, and you can then check and see if maybe you want to remove some files if these are no longer needed.

In cases when the inode usage is higher due to many incoming emails or many temporary/cache/session files – we recommend an upgrade to avoid reaching the limit again in future.

 

 

If you want to learn more about Word Press check out our WordPress guides:

  1. WordPress pros and cons 2. WordPress web design |Domain registration 3. 50 most common WordPress issues and how to fix them. 4. IS BLUEHOST NECESSARY FOR WORDPRESS? 5.WordPress Monster insights guide 6. WordPress Facebook Group 7.how to install a 3D library into WordPress 8.50 ways wordpress can help you to grow your business in 2023 9. WordPress Website design 10. WordPress website design services 11.50 most useful wordpress plugins in 2023 12. WordPress integrations 13.Best WordPress Templates

Leave a comment

Explore
Drag