0

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 :

they're virtual filesystems, so since they are root folders for their filesystem, they also have inode 2

But on my system (Debian 11, EXT4), all those directories have inode #1 :

$ stat /sys | grep Inode
Device: 14h/20d Inode: 1           Links: 13

$ stat /proc | grep Inode Device: 15h/21d Inode: 1 Links: 341

$ stat /run | grep Inode Device: 17h/23d Inode: 1 Links: 33

$ stat /dev | grep Inode Device: 5h/5d Inode: 1 Links: 22

EXT4's doc states that Inode #1 is for List of defective blocks.

What's going on there ? Why don't those directories have inode #2, like they apparently have with other people ?

ChennyStar
  • 1,743
  • 1
    Only disk filesystems are ext4. /proc /sys are (always) virtual filesystems mocked-up by the kernel and cannot have bad blocks. /dev is usually either virtual or RAM-based, and /run is a usually RAM-based (tmpfs). Check mount | grep /blah. – dave_thompson_085 Jan 11 '24 at 07:17
  • I know they are virtual file systems. But it seems in most peoples' setup those dirs have inode #2, not #1 (see for example https://unix.stackexchange.com/questions/607640/why-inode-numbers-of-dev-and-run-are-same-as-that-of, https://askubuntu.com/questions/1073802/what-are-directories-if-everything-on-linux-is-a-file, https://unix.stackexchange.com/questions/408192/why-do-the-directories-home-usr-var-etc-all-have-the-same-inode-number-2, ...). Why do I have #1 ? – ChennyStar Jan 11 '24 at 07:27
  • 3
    @ChennyStar the posts you link to are over 3, 5 and 6 years respectively. I have an Ubuntu 18.04 system and an Ubuntu 20.04 system (both on kernel 5.4, over 3 years old now) which has inode 1 for /proc and /sys, and 2 for /dev and run. So things were not that constant even back then. And of course, any talk of ext4 is completely irrelevant to the discussion since none of these are ext4 filesystems. – muru Jan 11 '24 at 07:50
  • Anyway the title is misleading: these are not ext4. Title and tag should be amended. – A.B Jan 11 '24 at 07:52
  • @muru - ok thanks I get it now – ChennyStar Jan 11 '24 at 08:02
  • 1
    Note that the quote in that AskUbuntu answer refers to an U&L question where it is clearly seen that the virtual filesystems do not necessarily have inode 2. – Kusalananda Jan 11 '24 at 08:27
  • @Kusalananda - yes indeed, the AskUbuntu answer is wrong on that particular point (stating that virtual filesystems'root all have inode 2). – ChennyStar Jan 11 '24 at 08:31
  • Anyway, in case someone else is as confused as I was, some useful links that helped me understand : https://www.reddit.com/r/linuxquestions/comments/swmqeg/inode_1/, https://superuser.com/questions/1454561/why-proc-and-sys-have-inode-1 and https://stackoverflow.com/questions/2099121/why-do-inode-numbers-start-from-1-and-not-0/2109363#2109363. – ChennyStar Jan 11 '24 at 08:33
  • I suggested an edit to the AskUbuntu answer, hopefully clarifying that text. I don't have an account on that site, so we'll see if they accept my anonymous edit suggestion. – Kusalananda Jan 11 '24 at 08:37
  • @Kusalananda - I'm not familiar with how "edit suggestions" work, but note that the author of the post hasn't been seen in 2 years (https://askubuntu.com/users/295286/sergiy-kolodyazhnyy) – ChennyStar Jan 11 '24 at 08:39
  • @ChennyStar That's a minor issue as edits go into the edit review queue and may be processed by anyone with access to that queue. – Kusalananda Jan 11 '24 at 08:41
  • @Kusalananda - ok thanks, good to know – ChennyStar Jan 11 '24 at 08:41

0 Answers0