Why does '/' have the inode 2?
5,663
Solution 1
Inode 0 is used as a NULL value to indicate that there is no inode.
Inode 1 is used to keep track of any bad blocks on the disk; it is essentially a hidden file containing the bad blocks. Those bad blocks which are recorded using e2fsck -c
.
Inode 2 is used by the root directory, and indicates starting of filesystem inodes.
Solution 2
In ext4 the Inode 1 is used for bad blocks. The link below the the kernel site describes which Inode is used for what purpose.
https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Special_inodes
Related videos on Youtube
Author by
yzyzsun
Updated on September 18, 2022Comments
-
yzyzsun over 1 year
On many *nix systems like OS X and Ubuntu, We can see the inode of root directory is 2. Then what is the inode 1 used for?
-
Michael Homer almost 9 yearsThis will differ by filesystem; are you interested in a particular one? Commonly inode 1 is used for the list of bad blocks, but it's not required.
-
Sergiy Kolodyazhnyy almost 5 yearsThe "why" is really "because ext4 developers decided to do so". AFAIK inode for
/
differs between filesystems, and it's not specified anywhere in POSIX standard. It may have been so in original AT&T UNIX or System V, of course, so can be considered a tradition,but it'd definitely not set in stone.
-
-
Joshua about 6 yearsWe should note that except for 0 the values come from tradition and are not really fixed. For example minixfs has / as inode 1 and badblocks as whatever inode /.badblocks is.