Btrfs: Find file names with checksum errors

dmesg | grep -Po 'csum failed ino\S* \d+' | sort | uniq | xargs -n 3 find / -inum 2> /dev/null
Btrfs reports the inode numbers of files with failed checksums. Use `find` to lookup the file names of those inodes.

By: Sepero
2014-03-20 06:27:15

4 Alternatives + Submit Alt

What Others Think

Er... I don't have a damage btrfs filesystem to hand, but surely that command can't work. grep is going to output sets of four "words", e.g. csum failed ino 1234 csum failed ino 5678 You want to extract just the number (but you don't). Next, sort and uniq (sort -u would be more efficient). Then you "xargs -n3" to find. find can only take one parameter to -inum. Therefore most calls to find will fail. I'd change the command to: dmesg | grep -Po 'csum failed ino\S* \d+' | awk '{print $4}' | sort -u | xargs -n 1 find / -inum 2> /dev/null
flatcap · 356 weeks and 2 days ago
@flatcap I had a Btrfs with corrupted files, so indeed it did work, but perhaps it wasn't portable? In my usage, the "xargs -n3" made it chop off all but the 4th argument (inode number). I have little experience with xargs. Anyway, I posted your suggestion as an alternative because I like it also.
Sepero · 356 weeks ago
@flatcap Perhaps this output on my system explains it, and all errors from the original command were simply redirected to /dev/null. $ echo "1 2 3 4" | xargs -n3 echo 1 2 3 4
Sepero · 356 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: