How to find the file at a certain btrfs inode

by user192749   Last Updated August 18, 2017 13:00 PM

I have a corrupt file according to btrfs

BTRFS info (device sdb1): csum failed ino 367 off 310013952 csum 1601485211 expected csum 3692975992

I assumed ino 367 means inode 367, so I can use find and try to restore the file. However find /path -inum 367 finds nothing. Anyone know how to find the corrupt file?

Tags : btrfs inode

Answers 3

I'm not sure why find command didn't work for you. May be ino#367 deleted? For me, both find and btrfs-debug-tree seems to be working fine.

$ find  /btrfs/ -inum 257
$ ls -li /btrfs/100kbfile.txt 
257 -rw-r--r--. 1 root root 102400 Nov 25 21:07 /btrfs/100kbfile.txt

You can also try using 'btrfs-debug-tree' and grep for the objectid.

./btrfs-debug-tree  /btrfs/partition | grep -A2 257

find your inode/objectid from output. You can see the name associated with objectid 257.

location key (257 INODE_ITEM 0) type FILE

namelen 13 datalen 0 name: 100kbfile.txt

March 09, 2016 13:39 PM

The method "find /path -inum xxx" works with newer kernels, issue is a bug in older brtfs kernel code.

March 11, 2016 03:46 AM

man btrfs-inspect-internal says:

   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


           verbose mode, print count of returned paths and ioctl()
           return value


  • sudo btrfs inspect-internal inode-resolve 15380 /home
Tom Hale
Tom Hale
August 18, 2017 12:42 PM

Related Questions

Relinking a deleted file

Updated July 28, 2017 08:00 AM

Could swap use many inodes?

Updated July 09, 2018 14:00 PM

Lustre: find where inodes are being used

Updated May 10, 2017 21:00 PM