What does it mean to have the same inode number?

What does it mean to have the same inode number?

Inodes and File System Size. Each inode has an inode number, which is unique within a file system. The same inode number might appear in more than one file system. However, the file system ID and inode number combine to make a unique identifier, regardless of how many file systems are mounted on your Linux system.

Is inode hard link?

A hard link is a direct reference to a file via its inode. You can also only hardlink files and not directories. By using a hardlink, you can change the original file’s contents or location and the hardlink will still point to the original file because its inode is still pointing to that file.

Can a directory have the same inode number?

Since both directory entries have the same inode number, they point to the same item on the disk (ie the same physical file). Of course, inode numbers, as explained above, are partition-specific. So, duplicating an inode number on a different partition would not work as expected.

How can I change the inode number of a file?

You could probably use debugfs to “change” an existing file’s inode number, by copying the contents of one inode to another, then updating any directory entries to point to the new inode and deallocating the old one. So you could create your file with any inode number, then “change” it to the desired one.

How is the link count of an inode calculated?

link count in the inode keeps track of how many directories contain a name-number mapping for that inode. If an inode has only one name-number map (only one name), its link count is one. If the inode has two name-number maps (two names), its link count is two.

What happens when a link to an inode goes to zero?

The “rm” command will delete a name-inode map from a directory. When a link count goes to zero in an inode, that means that no directory points to the inode and Unix is free to release and reclaim the disk space used by the inode and its associated disk blocks.