Skip to main content
2 of 5
clarify question
Yann
  • 211
  • 3
  • 6

How to dump the list of used inodes on a ext4 filesystem by using debugfs?

After a hard drive I/O failue and an attempt at fsck recovery, I've got a disk where the numbers of used inode is vastly different according to 'df -i' and according to 'find . | wc -l':

[yan@machine data]$ df -i /run/media/yan/data/
Filesystem       Inodes IUsed    IFree IUse% Mounted on
/dev/sdc4      51200000 74199 51125801    1% /run/media/yan/data
[yan@machine data]$ sudo find /run/media/yan/data | wc -l
23690

So it seems I have a lot of unconnected inodes, despite fsck telling me partition is clean (even with -f). I'd like to know where the (74199-23690) missing inodes are. I know there are still on the disk because I've managed to get back 50k files using photorec.

So I've try to use debugfs, but I can't find anywhere in the manual a way to dump the list of allocated inodes. (And most post online use find/ls -i to list inodes, which won't work in my case).

Does any one know a way to get the list of inodes used according to df/fsck ?

For now, I'm considering to inefficiently bruteforce with something along the lines of :

for i in `seq 1 $NMAX`; do debugfs -R 'ncheck $i' | grep $i; done > inodelist

with NMAX big enough, but there is surely more efficient way, no ?

Yann
  • 211
  • 3
  • 6