BTRFS RAID5: unrepaired sectors detected

Finding the broken file

While scrubbing my BTRFS RAID 5 filesytem for the first time in four years the scrub got canceled due to the following error according to dmesg:

BTRFS error (device sdc1): unrepaired sectors detected, full stripe 15994477215744 data stripe 0 errors 4

This message sounds scary and normally BTRFS should be able to recover the data. Why this did not work will stay unclear for now. I had two or three unclean shutdowns in all these years so maybe I triggerd one of the main bugs they always warn you about. Here is how I found out which file is broken. Fist I dissected the message: 15994477215744 is the starting byte number of that stripe. data stripe 0 means it’s the first block in that stripe. So we can pass 15994477215744 directly to btrfs:

:-$ btrfs inspect-internal logical-resolve 15994477215744 /mnt

And that’s it. That’s the broken file you need to delete and restore from backup.

Data Stripe is not 0

If data stripe is not 0 you need to do some calculations first. A stripe in BTRFS is 64k bytes long. You need to add 64 bytes times the stripe number to the starting byte range. For example:

full stripe: 15994477215744
data stripe 0 = 15994477215744 + 64 * 0
data stripe 1 = 15994477215744 + 64 * 1
data stripe 2 = 15994477215744 + 64 * 2

You should notice the pattern by now. Pass your calculated result into logical-resolve.

Subvol XYZ could not be accessed: not mounted

If you are greeded with an error like

:-$ btrfs inspect-internal logical-resolve 15994477215744 /mnt
inode 97687 subvol nas could not be accessed: not mounted

That means you need to mount the subvolume directly. You need the id of the subvolume for this:

:-$ btrfs subvol list /mnt
ID 8430 gen 2829785 top level 5 path nas

The id for my subvolume named “nas” is 8430. Now mount it:

:-$ mkdir /lol
:-$ mount -t btrfs -o subvolid=8430 /lol

Now re-issue the logical-resolve command but point it to the new mountpoint:

:-$ btrfs inspect-internal logical-resolve 15994477215744 /lol

Further reading:

Du hast einen Kommentar, einen Wunsch oder eine Verbesserung? Schreib mir doch eine E-Mail! Die Infos dazu stehen hier.

🖇️ = Link zu anderer Webseite
🔐 = Webseite nutzt HTTPS (verschlüsselter Transportweg)