I know that symlinks have a separated inode from the original file and that they only point for the inode containing the data. My question is, where is the hardlink name stored if there's no field in the inode structure refering to "name". I know that this could be a a relatively easy question, but as all hardlinks have the same inode number i assume that no inode is created when creating a hard link.
Asked
Active
Viewed 2,355 times
1
-
An inode is allocated when creating the first hard link to that inode. No additional inodes are allocated when linking additional directory entries. – user4556274 Oct 16 '17 at 14:51
1 Answers
5
The names for the file are stored in the directory.
In simple terms, a directory on Linux is just a mapping of names to inodes. When you use mv
to rename/move a file, only the mappings in the directories change. This allows you to have hard links to the same inode with different names as long as the hard links are on the same file system partition.
More info here.

Hunter.S.Thompson
- 8,954

Munir
- 3,332
-
Oh ok , i thought that there was some sort of index besides the directories to map names -> inodes. Thanks. – andrediasesp Oct 16 '17 at 14:52
-
1There is on some filesystems. NTFS, for example, contains a list of the file's names in each MFT entry. But on filesystem formats with mostly the traditional Unix design such as EXT, FFS, or UFS this is not the case. – JdeBP Oct 16 '17 at 16:36
-
I'm sorry to bother you again but i came up with a new question. "." (current directory) and ".." (parent directory) have to be alias defined in each inode right? Where's it defined? – andrediasesp Oct 18 '17 at 09:00
-
1@laflame1x0
.
and..
are just links to the current and parent directory. They are also stored in the directory just like all other links. Here is a more detailed description of the directory structure forext
family of file systems – Munir Oct 18 '17 at 16:03