1

Please see below output: In below output, the inode numbers of /dev and /run are same and equal to 2. The inode numbers of ./ and ../(could be a special case as ../ should point to ./) are also 2 and 2. How can dev and run and / have the same inode as there contents are entirely different.

$ll -i
total 84
      2 drwxr-xr-x  20 root root  4096 Aug 18 01:21 ./
      2 drwxr-xr-x  20 root root  4096 Aug 18 01:21 ../
     12 lrwxrwxrwx   1 root root     7 Aug 18 01:19 bin -> usr/bin/
1048577 drwxr-xr-x   4 root root  4096 Sep  1 15:53 boot/
5636097 drwxr-xr-x   2 root root  4096 Aug 18 01:21 cdrom/
      2 drwxr-xr-x  23 root root  4920 Sep  3 11:20 dev/
 262145 drwxr-xr-x 144 root root 12288 Sep  3 09:34 etc/
 524289 drwxr-xr-x   3 root root  4096 Aug 18 01:22 home/
     13 lrwxrwxrwx   1 root root     7 Aug 18 01:19 lib -> usr/lib/
     14 lrwxrwxrwx   1 root root     9 Aug 18 01:19 lib32 -> usr/lib32/
     15 lrwxrwxrwx   1 root root     9 Aug 18 01:19 lib64 -> usr/lib64/
     16 lrwxrwxrwx   1 root root    10 Aug 18 01:19 libx32 -> usr/libx32/
     11 drwx------   2 root root 16384 Aug 18 01:18 lost+found/
3932161 drwxr-xr-x   5 root root  4096 Aug 18 17:23 media/
1572865 drwxr-xr-x   7 root root  4096 Sep  2 14:19 mnt/
9175041 drwxr-xr-x   4 root root  4096 Aug 28 23:46 opt/
      1 dr-xr-xr-x 359 root root     0 Sep  3 10:18 proc/
5505025 drwx------  11 root root  4096 Sep  1 17:49 root/
      2 drwxr-xr-x  43 root root  1320 Sep  3 11:24 run/
     17 lrwxrwxrwx   1 root root     8 Aug 18 01:19 sbin -> usr/sbin/
2097153 drwxr-xr-x  11 root root  4096 Aug 26 20:34 snap/
 655361 drwxr-xr-x   2 root root  4096 Jul 31 21:57 srv/
      1 dr-xr-xr-x  13 root root     0 Sep  3 10:18 sys/
4325377 drwxrwxrwt  22 root root  4096 Sep  3 11:25 tmp/
1310721 drwxr-xr-x  14 root root  4096 Jul 31 21:58 usr/
8388609 drwxr-xr-x  14 root root  4096 Jul 31 22:05 var/

Same with /sys and /proc. There contents are different but they share the same inode.

Note: I have only one ext4 partition for entire system. And swap is off, though i don't think this matters.

Edit - The already asked Q pointed by Stephen answers to good extent. Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?
But I am interested in knowing few more details regarding how this works.

At the time of Linux installation, i have mentioned only one filesystem (/dev/sda1 -> ext4 -> / ). So for dev, run, proc, sys - Linux is creating these addition FS which is now inferable.
I am aware that /proc is a Virtual FS and is in memory and not on any HDD/SSD. Could some one explain what is the case with /dev, /run and /sys. Do they exist on HDD (if so what is there location if it can be meaningfully traced).

samshers
  • 678

1 Answers1

4

Because they're on different file systems.

It's the device_id:inode tuple which uniquely identifies a file, not just the inode.

# mount
...
/dev/sda8 on / type ext4 (rw,relatime,errors=remount-ro)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=816612k,mode=755)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=4032552k,nr_inodes=1008138,mode=755)