Quickly find which file(s) belongs to a specific inode number

filesinodesearch

I know of this command:

find /path/to/mountpoint -inum <inode number>

but it is a very slow search, I feel like there has to be a faster way to do this. Does anybody know a faster method?

Best Answer

For an ext4 filesystem, you can use debugfs as in the following example:

$ sudo debugfs -R 'ncheck 393094' /dev/sda2 2>/dev/null
Inode   Pathname
393094  /home/enzotib/examples.desktop

The answer is not immediate, but seems to be faster than find.

The output of debugfs can be easily parsed to obtain the file names:

$ sudo debugfs -R 'ncheck 393094' /dev/sda2 | cut -f2 | tail -n2 > filenames
Related Question