0

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: /run
  Size: 940         Blocks: 0          IO Block: 4096   directory
Device: 16h/22d Inode: 2           Links: 32
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-09-10 10:22:18.198727482 +0800
Modify: 2018-09-10 02:47:58.655999930 +0800
Change: 2018-09-10 02:47:58.655999930 +0800
 Birth: -

The simple question is "Why do they have the same inode?" The /run directory is different from / and /run is not hardlink to /.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
Sergiy Kolodyazhnyy
  • 16,187
  • 11
  • 53
  • 104
  • The base directory of any Ext2/3/4 file system uses inode 2 (see [this question](https://unix.stackexchange.com/q/408192/86440)). However `/run` is usually a `tmpfs` and that rule doesn’t apply — what does `mount | grep 'on /run '` output? – Stephen Kitt Sep 10 '18 at 04:34
  • @StephenKitt Thanks for finding that. So essentially it's because /run is root directory since it's a virtual filesystem. – Sergiy Kolodyazhnyy Sep 10 '18 at 04:43
  • Essentially yes, but that doesn’t explain everything because [`tmpfs` file systems don’t have a fixed root inode](https://stackoverflow.com/q/4411701/4500798). – Stephen Kitt Sep 10 '18 at 04:47
  • For me it's `Inode: 14511` and it's `tmpfs`. `/` is inode 2 though (ext4). `/tmp` is tmpfs and inode 2860. Fedora 25 dom0 under Qubes OS 4.0 –  Sep 10 '18 at 04:50

0 Answers0