Questions tagged [inode]

For question pertaining to the inode (index node), a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. Use this tag for questions about the inode data structure itself or questions about issues arising from querying or managing inodes in the scope of a filesystem.

An inode (sometimes referred to as an index node) is the file structure as part of the metadata of many file systems. Each inode typically contains all the information about one file or directory, except its content and name.

The number of inodes (and thus total number of files and directories) is often fixed at filesystem creation; thus they're frequently over-provisioned. The mkfs default is typically several percent of the total size of the filesystem. The size of an individual inode varies by filesystem; Linux ext[234] uses 128- or 256-byte inodes, for example.

The metadata stored includes the following:

  • Inode number
  • Access Control List (ACL)
  • Extended attribute
  • Direct/indirect disk blocks (lists where the actual file contents is stored)
  • File access, change and modification time
  • File deletion time
  • File generation number
  • File size
  • File type
  • Group Number of links
  • Owner
  • Permissions
  • Status flags

Examples

$ touch "test1"
$ touch "test2"
$ ls -il test*
1079211 -rw-r--r-- 1 root users 0 Oct 12 15:13 test1
1079212 -rw-r--r-- 1 root users 0 Oct 12 15:13 test2

The first column is the inode. In addition, both stat and ls -i will give you the inode number. The find command can search for a file by inode number using -inum.

A file's inode does not store the file's name. (Indeed, hardlinked files share the same inode; a file can have many names). Instead, that is stored by the directory containing the file. If the filesystem is damaged, and the directory entries pointing to an inode are lost, fsck may re-connect the inode (often under a generated name) to "lost+found".

Each file on a filesystem has a unique inode number (though of course two files on two different filesystems can have the same inode number). As above, hardlinks (as created by ln) share the same inode, so this can be used to confirm two file names are hardlinked together.

Further reading

Find where inodes are being used

What is a Superblock, Inode, Dentry and a File?

How can I increase the number of inodes in an ext4 filesystem?

External reference

inode (Wikipedia)

Definitions - 3.176 File Serial Number

Inode Definition

321 questions
238
votes
8 answers

Find where inodes are being used

So I received a warning from our monitoring system on one of our boxes that the number of free inodes on a filesystem was getting low. df -i output shows this: Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 524288 422613 …
phemmer
  • 70,657
  • 19
  • 188
  • 223
158
votes
5 answers

What is a Superblock, Inode, Dentry and a File?

From the article Anatomy of the Linux file system by M. Tim Jones, I read that Linux views all the file systems from the perspective of a common set of objects and these objects are superblock, inode, dentry and file. Even though the rest of the…
Navaneeth Sen
  • 9,369
  • 17
  • 58
  • 65
91
votes
12 answers

How do I count all the files recursively through directories

I want to see how many files are in subdirectories to find out where all the inode usage is on the system. Kind of like I would do this for space usage du -sh /* which will give me the space used in the directories off of root, but in this case I…
xenoterracide
  • 57,918
  • 74
  • 184
  • 250
77
votes
6 answers

How can I increase the number of inodes in an ext4 filesystem?

I had a problem (new to me) last week. I have a ext4 (Fedora 15) filesystem. The application that runs on the server suddenly stopped. I couldn't find the problem at first look. df showed 50% available space. After searching for about an hour I saw…
piovisqui
  • 873
  • 1
  • 6
  • 6
74
votes
5 answers

Quickly find which file(s) belongs to a specific inode number

I know of this command: find /path/to/mountpoint -inum but it is a very slow search, I feel like there has to be a faster way to do this. Does anybody know a faster method?
Alex
  • 936
  • 1
  • 6
  • 9
72
votes
4 answers

List all files with the same inode number?

Let's say when I do ls -li inside a directory, I get this: 12353538 -rw-r--r-- 6 me me 1650 2013-01-10 16:33 fun.txt As the output shows, the file fun.txt has 6 hard links; and the inode number is 12353538. How do I find all the hard links for the…
its_me
  • 13,709
  • 23
  • 54
  • 52
39
votes
5 answers

Can a file be retrieved by its inode?

I ran following commands in the order specified: $ln a b $ls -i a b 523669 a 523669 b $rm -f a $ls -i b 523669 b I concluded from this test that the command rm actually removes only the filename (a in this test) instead of the file, as the inode…
user43312
  • 951
  • 2
  • 12
  • 20
35
votes
5 answers

Can I run out of disk space by creating a very large number of empty files?

It is well-known that empty text files have zero bytes: However, each of them contains metadata, which according to my research, is stored in inodes, and do use space. Given this, it seems logical to me that it is possible to fill a disk by purely…
luchonacho
  • 793
  • 2
  • 11
  • 28
35
votes
2 answers

why inode value changes when we edit in "vi" editor?

When I edit a file in "vi" editor the inode value of the file is changing. But when edited with cat command the inode value is not changing.
monu
  • 1,725
  • 6
  • 20
  • 28
32
votes
2 answers

Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?

I find that under my root directory, there are some directories that have the same inode number: $ ls -aid */ .*/ 2 home/ 2 tmp/ 2 usr/ 2 var/ 2 ./ 2 ../ 1 sys/ 1 proc/ I only know that the directories' names are kept in the parent directory, and…
youxiao
  • 335
  • 3
  • 5
30
votes
2 answers

Why does a software package run just fine even when it is being upgraded?

Say I am running a software, and then I run package manager to upgrade the software, I notice that Linux does not bring down the running process for package upgrade - it is still running fine. How does Linux do this?
Howard
  • 5,149
  • 5
  • 30
  • 34
29
votes
3 answers

What is an orphaned inode?

I understand what an inode is but what is the exact definition of an orphaned inode? I don't really get what that means. UPDATE There was a time that a server I was managing ran out of inodes but when I would do a df -h it showed me that the server…
ninjacoder
  • 391
  • 1
  • 3
  • 5
28
votes
2 answers

How can I find the number of files on a filesystem?

I want to know how many files I have on my filesystem. I know I can do something like this: find / -type f | wc -l This seems highly inefficient. What I'd really like is to do is find the total number of unique inodes that are considered a…
beatgammit
  • 7,453
  • 10
  • 31
  • 32
22
votes
5 answers

Is '..' really a hard link?

This is a bit of a theoretical question, but it's important to use proper names for things. In UNIX/Linux file systems, .. points to the parent directory. However, we know that hard links cannot point to directories, because that has the potential…
dr_
  • 28,763
  • 21
  • 89
  • 133
22
votes
3 answers

Why is the inode table usually not resizable?

Unix file systems usually have an inode table, and the number of entries in this table is usually fixed at the time the file system is created. This sometimes leads to people with plenty of disk space getting confusing error messages about no free…
Mark VY
  • 323
  • 2
  • 6
1
2 3
21 22