LLI Wiki — My Digital Knowledge Base

Find a file by its inode number on Linux

Find the path of a file from its inode number using find, debugfs (ext4) or btrfs inspect-internal.

A file can be found from its inode number, for example when a diagnostic tool only reports that identifier.

Identify the file system

sudo lsblk -o NAME,FSTYPE,LABEL,UUID,MOUNTPOINT

Search with find

On any mounted file system:

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

ext4

sudo debugfs -R 'ncheck <inode number>' /dev/sda2 2>/dev/null

ncheck prints the path of the files linked to the inode on the given device.

btrfs

sudo btrfs inspect-internal inode-resolve <inode number> /home

The last argument is the mount point of the btrfs file system.

Mastodon LLIMastodon SocialFosstodon