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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
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 seem to be better than
The output obtained can be easily parsed to obtain the filename.
inode-resolve [-v] <ino> <path> (needs root privileges) resolve paths to all files with given inode number ino in a given subvolume at path, ie. all hardlinks Options -v verbose mode, print count of returned paths and ioctl() return value
sudo btrfs inspect-internal inode-resolve 15380 /home
You could look at the fsdb command, found on most Unices, and available somewhere for Linux I am sure. This is a powerful command allowing you to to access the in-core inode structure of files, so be careful. The syntax is also very terse.
While fsdb won't actually let you discover the filename of the inode, it does allow you to directly access the inode when you specify it, in essence "porting" you to the file itself (or at least it's data block pointers) so it's quicker in that respect than the find ;-).
Your question doesn't specify what you want to do with the file. Are you perchance decoding NFS filehandles?