1

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 23:53 boot
       2 drwxr-xr-x  19 root root  4200 Oct  6 00:14 dev
       2 drwxr-xr-x  12 root root  4096 Sep 27 08:48 home
...
       2 drwxr-xr-x  34 root root   940 Oct  6 00:14 run
...

For example, when I am in the home directory, inode number 2 appears as the parent folder.

:/home$ ls -lai
total 60
       2 drwxr-xr-x 12 root       root        4096 Sep 27 08:48 .
       2 drwxr-xr-x 19 root       root        4096 Apr 30 18:26 ..
...

Many file systems connected to the system have inode number 2. Why do I return to the / directory and not one of the other 2 inode folders when I use ".." ? After all, they are all folders with the same inode of separate file systems.

testter
  • 1,410
  • What does the inode number have to do with directory navigation? – muru Oct 06 '21 at 04:38
  • @muru So what is it that allows us to navigate directories? – testter Oct 06 '21 at 04:42
  • 1
  • @muru Another question came to my mind. For example, when I delete a folder, I am not actually deleting the data inside the folder. I delete the link of the folder with its unique inode value. Since this inode value knows where the table that matches the names and inode values of the files and folders in the folder is on the disk, although the files and folders are on the disk, I cannot access these contents because I do not have a link to the table that matches the names and inode values. – testter Oct 06 '21 at 05:20
  • @muru So in the end, inodes are used to provide access privileges while browsing directories. If I delete the link that depends on the inode value, I won't be able to navigate in the folder either. In other words, can we say that inode values are a structure that helps us navigate the file system hierarchy within our authority? – testter Oct 06 '21 at 05:20
  • 1
    That would be true of files. But for directories, the directory has to be empty in the first place before it can be deleted. – muru Oct 06 '21 at 06:16
  • @muru I was thinking that when I delete a folder with full contents with rm -rf it is quickly deleted, only the link that depends on the folder's inode value, and all the contents of the folder are no longer accessible. So am I wrong about this? Look at this: https://i.stack.imgur.com/O0vpv.png – testter Oct 06 '21 at 06:28
  • 2
    No, it has to delete every file and directory inside (recursively - hence the -r). – muru Oct 06 '21 at 06:33
  • @muru You can force unlink a directory, but you need to run a fsck afterwards. So it's still impractical. – Kusalananda Oct 06 '21 at 06:43
  • @they I guess that's using some hack specific to the filesystem in question? I don't think standard interfaces allow that – muru Oct 06 '21 at 07:04
  • @muru Yes, this would not be done using standard tools. – Kusalananda Oct 06 '21 at 07:11

0 Answers0