Skip to main content

Inodes and the Linux filesystem

What's so important about inodes that I need to keep an eye on them? Find out in this introductory article.
Index nodes
Image by Bruno /Germany from Pixabay

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. Let's take a look at what precisely an inode is and what it does for us.

What is an inode?

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.

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.


Inodes are a great place to start if you are interested in learning more about filesystems and their structures. How the smallest units of data are labeled and indexed is important information to know. Some far more advanced operations can be done concerning inodes. For example, you can open an inode and read the contents on the file. This ability gives you an even deeper look into what metadata is stored there. Hopefully, this high-level look provides you with a baseline for your inode exploration.

[ Free online course: Red Hat Enterprise Linux technical overview. ]

Topics:   Linux   Storage  
Author’s photo

Tyler Carrigan

Tyler is a community manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. More about me

Related Content