I learned that in fact the file names and the files themselves are not directly related. The name files themselves do not have, they have only indexes. And the file system (in this case, ext2 ) associates invented names with file indices. And hard links are two different names for one index, but hard links cannot be created to a directory. I went into / and the ls -il got something like the following:

  1 dr-xr-xr-x 232 root root 0 июн 26 17:14 proc 16252929 drwx------ 5 root root 4096 июн 26 17:12 root ......................................................... 1 dr-xr-xr-x 13 root root 0 июн 26 22:56 sys 

Where the first number is the inode. It turns out that the proc and sys directories have one file? How is this possible? After all, there should be no hard links, and the number of these links is different ( 232 and 13 )

  • proc and sys are virtual directories. In fact, they are not on the disk. - Alexey Ten
  • Run, for example, mount and see what and where mounted. By the way, they also have a size of zero. - Alexey Ten
  • @AlexeyTen they are, because the mount point must be a directory - eri
  • Yes, but after mounting the original catalog is not visible - Alexey Ten
  • Poor wrote, yes - Alexey Ten

2 answers 2

The fact is that the numbers of file descriptors ( inodes ) are unique only within the same file system ( FS ) and for different FS they, of course, can be repeated.

The /proc and /sys directories usually mounted virtual linux file systems, which seems to be described in the case of the question. And in ls -i displays the ls -i numbers of the root directories of these particular file systems for their mount points.

In order to see the true inode numbers of these directories in the root file system, you can, for example, simply unmount the above directories (do it with caution) or mount the root file system to another location:

 mkdir -p /mnt/root mount /dev/<MY_ROOT_DEVICE> /mnt/root ls -li /mnt/root 

    mount does not cover the contents of the directory, but the directory itself is a new link. Link 1 means that you need to access the virtual kernel file system (there are still dev / pts), link 2 that a hard disk is mounted there.

    If this point is unmounted, then ls will show the real index of this directory.