After btrfs scrub, how do you get the list of affected files?

1

I just tried to use btrfs send for a backup but it ended up giving me an io error. I ran btrfs scrub, which reported 32 unrepairable blocks on my raspi's sd card.

The obvious way to fix this is to get fresh copies of the affected files, but how do you find out which files they are?

Everywhere I've looked online, wikis and people only ever mention that you can do a scrub and that typically everything ends well if you have raid, not how to get to the next step after being told there are errors.

Marnes

Posted 2018-09-16T18:05:59.490

Reputation: 141

I hope you can get this information from Btrfs; but in case you can't, this answer says you can verify a single file just by reading it. Worst case scenario is you read all files one by one.

– Kamil Maciorowski – 2018-09-16T18:35:47.587

Yes, there is that, but... just as you posted this, I actually found an answer. – Marnes – 2018-09-16T22:01:55.520

Answers

1

Turns out dmesg will list all btrfs checksum errors with file paths after a scrub. Run
dmesg --clear btrfs scrub start -B / dmesg
to get a rough overview of the bad files.

Marnes

Posted 2018-09-16T18:05:59.490

Reputation: 141

1pitfall: the dmesg entries list corrupt files by their simple path. Deleting those files, followed by scrubs, syncs, and fstrims, didn't remove the errors. The cause was snapshots still referencing the bad blocks, which wasn't obvious from the messages. Deleting the snapshots as well finally removed all errors. – Marnes – 2018-09-16T22:31:47.607