Can two files on two separate filesystems share the same inode number?

An inode number is only unique on a single file system. One example you’ll run into quickly is the root inode on ext2/3/4 file systems, which is 2:

$ ls -id / /home
2 /    2 /home

If you run (assuming GNU find)

find / -printf "%i %p\n" | sort -n | less

on a system with multiple file systems you’ll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).

When you’re looking for a file by inode number, you can use find’s -xdev option to limit its search to the file system containing the start path, if you have a single start path:

find / -xdev -inum 12582925

will only find files with inode number 12582925 on the root file system. (-xdev also works with multiple start paths, but then its usefulness is reduced in this particular case.)

It's the combination of inode number and device number (st_dev and st_ino in the stat structure, %D %i in GNU find's -printf) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).

Some find implementations also have a -samefile predicate that will find files with the same device and inode number. Most [/test implementations also have a -ef operator to check that two files paths refer to the same file (after symlink resolution though).


Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major —the general class of device— and dev_minor —the specific instance—).

The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).

As stated on inode(7):

Device where inode resides

Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).

Inode number

Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers may be used by different filesystems, which is the reason that hard links may not cross filesystem boundaries).