No file-name in Inode information

inode

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.

Best Answer

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.

Related Question