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. ]


저자 소개

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.

UI_Icon-Red_Hat-Close-A-Black-RGB

채널별 검색

automation icon

오토메이션

기술, 팀, 인프라를 위한 IT 자동화 최신 동향

AI icon

인공지능

고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트

open hybrid cloud icon

오픈 하이브리드 클라우드

하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요

security icon

보안

환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보

edge icon

엣지 컴퓨팅

엣지에서의 운영을 단순화하는 플랫폼 업데이트

Infrastructure icon

인프라

세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보

application development icon

애플리케이션

복잡한 애플리케이션에 대한 솔루션 더 보기

Virtualization icon

가상화

온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래