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

332 questions
6
votes
2 answers

What determines the number of inodes available on a disk?

Is it based on a number determined when formatting a hard drive? For instance: $ df -Ti / Filesystem Type Inodes IUsed IFree IUse% Mounted on /dev/dm-0 ext4 983040 95683 887357 10% / Where does that 983040 come from? Can we…
4
votes
1 answer

Is it possible to change the inode of a file. What are the different conditions when the inode of a file can be changed?

Is it possible to change the inode of a file. What are the different conditions when the inode of a file can be changed ?
2
votes
1 answer

How to speed up directory listing on high-inode partitions?

I have almost 7,000 files in a single directory which makes loading that particular directory a tedious and time-consuming one. Is there any way to list and perform operations on files in that directory faster rather than distributing the files into…
1
vote
1 answer

open a file by inode number

Is there any way to find exactly the blocks allocated to a inode, and view that file? I don't care if I have to be on a live cd, but i need to do this for example: cat verylongsentice > a ls -i a 101010 a ln a /some/random/path rm a inode_find…
jp_
  • 27
1
vote
0 answers

How do directories with inode number 2 in different file systems know that they need to go back to the root directory?

I know that the same inode can be used in different file systems. For example, home run dev boot and / directory have inode number 2 because they are the first directories in file systems. $ ls -li 2 drwxr-xr-x 4 root root 4096 Sep 20…
testter
  • 1,410
1
vote
1 answer

Why no file-name in Inode information?

I know that symlinks have a separated inode from the original file and that they only point for the inode containing the data. My question is, where is the hardlink name stored if there's no field in the inode structure refering to "name". I know…
1
vote
1 answer

inode usage does not match the count

I have this inode usage: host:~ # df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/hda1 655360 655357 3 100% / but, if I run this command: for i in `find . -xdev -type d `;…
Diego
  • 11
0
votes
1 answer

Get the number of inode in a tree

How can I get the number of inodes used by files in a given directory tree? Important: including hidden directories under it, like .git
greg0ire
  • 3,005
0
votes
0 answers

Why do /dev, /run, /proc, /sys, ... have inode 1 (and not 2)?

I was reading the EXT4 doc about special inodes. It states that a FS root directory has inode #2. There are many posts in which people ask why directories like /dev, /proc, /run, /sys, and so on, have also inode #2, the answer usually being…
ChennyStar
  • 1,743
0
votes
3 answers

Question about inode and permission command

Can anyone tell me if this is true or false? Does the inode of a file have the addresses of blocks containing the file's content? Also for the permission command, there was a question asking that I have the right to change permissions for existing…
0
votes
0 answers

How to list orphaned inodes?

I have noticed that my hard drive space is being consumed by a long running process, but I was not able to find the file(s) that are consuming the space. I suspect the files are temporary files, using the open-and-remove technique to orphan the…
Eljay
  • 101
0
votes
0 answers

Why does the /run directory have inode 2?

It's well known that the / directory has inode number 2 (see also Why does '/' have the inode 2). And we also know that hard links share the same inode number. So far so good. Here's the confusing bit (notice the Inode: part): $ stat /run File:…