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.
Summary
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. ]
About the author
Tyler is the Sr. 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. Now that he has surfaced, he lives with his wife and son near Raleigh, where he worked as a data storage engineer before finding his way to the Red Hat team. He has written numerous technical documents, from military procedures to knowledgebase articles and even some training curricula. In his free time, he blends a passion for hiking, climbing, and bushcraft with video games and computer building. He is loves to read and enjoy a scotch or bourbon. Find him on Twitter or on LinkedIn.
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Artificial intelligence
Updates on the platforms that free customers to run AI workloads anywhere
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Customer support
- Developer resources
- Find a partner
- Red Hat Ecosystem Catalog
- Red Hat value calculator
- Documentation
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit