Disclaimer
This is more about btrfs than about Manjaro. I’m however not sure where else to post because I don’t want to feed Stack Overflow anymore, and I find Reddit kind of icky. I haven’t found other suitable places, so here we are. Do feel free to point me to a better place to get helpful support.
Assuming that at least a few people will read this and think “this guy is sure living dangerous”. You are correct. I actually have a nice automated, versioned online backup using Borg. I just haven’t bothered to include this particular file system in it. Yes, I should have. I also do kind of live on the edge with that crazy RAID set-up of mine, I’m aware. The thing is: I don’t do normal. In fact, nobody who uses Manjaro does normal, so let’s just embrace that, shall we? I’m just trying to make my specific not-normal setup work.
My machine
I’ve collected a set of 10 hard drives over the years and am using them in a heterogenous btrfs RAID 10 array. I actually started out with RAID 5, but stopped that when the write-hole started causing data loss whenever something crashed, or broke. RAID 10 should actually be quite safe. I thought…
Device info from inxi:
❯ sudo inxi -Dpzv1
System:
Kernel: 6.18.38-1-MANJARO arch: x86_64 bits: 64
Desktop: KDE Plasma v: 6.6.6 Distro: Manjaro Linux
CPU:
Info: 12-core AMD Ryzen 9 5900X [MT MCP] speed (MHz): avg: 1731
min/max: 567/4955
Graphics:
Device-1: Advanced Micro Devices [AMD/ATI] Navi 24 [Radeon RX 6400/6500
XT/6500M] driver: amdgpu v: kernel
Display: unspecified server: X.Org v: 21.1.24 with: Xwayland v: 24.1.13
driver: X: loaded: amdgpu unloaded: modesetting,radeon dri: radeonsi
gpu: amdgpu resolution: N/A
API: OpenGL v: 4.6 vendor: amd mesa v: 26.1.4-arch1.1 renderer: AMD
Radeon RX 6500 XT (radeonsi navi24 ACO DRM 3.64 6.18.38-1-MANJARO)
Info: Tools: api: clinfo, eglinfo, glxinfo, vulkaninfo
de: kscreen-console,kscreen-doctor gpu: corectrl wl: wayland-info
x11: xdriinfo, xdpyinfo, xprop, xrandr
Drives:
Local Storage: total: 8 TiB used: 2.18 TiB (27.3%)
ID-1: /dev/sda vendor: Patriot model: Burst size: 447.13 GiB
ID-2: /dev/sdb vendor: Western Digital model: WD6400AAKS-65A7B2
size: 596.17 GiB
ID-3: /dev/sdc vendor: Western Digital model: WD6400AACS-00G8B0
size: 596.17 GiB
ID-4: /dev/sdd vendor: Western Digital model: WD6400AAKS-65A7B2
size: 596.17 GiB
ID-5: /dev/sde vendor: Western Digital model: WD6400AAKS-00A7B0
size: 596.17 GiB
ID-6: /dev/sdf vendor: Toshiba model: HDWD120 size: 1.82 TiB
ID-7: /dev/sdg vendor: Western Digital model: WD2500JD-75HBB0
size: 232.83 GiB
ID-8: /dev/sdh vendor: Toshiba model: HDWD120 size: 1.82 TiB
ID-9: /dev/sdi vendor: Hitachi model: HDS7250SASUN500G 0711KSW1AH
size: 465.76 GiB
ID-10: /dev/sdj vendor: Hitachi model: HDS7250SASUN500G 0711KT275F
size: 465.76 GiB
ID-11: /dev/sdk vendor: Hitachi model: HDS7250SASUN500G 0711KT21WF
size: 465.76 GiB
Partition:
ID-1: / size: 446.83 GiB used: 374.45 GiB (83.8%) fs: btrfs dev: /dev/sda2
ID-2: /boot/efi size: 299.4 MiB used: 568 KiB (0.2%) fs: vfat
dev: /dev/sda1
ID-3: /bulk size: 3.06 TiB used: 1.76 TiB (57.4%) fs: btrfs dev: /dev/sdd2
ID-4: /home size: 446.83 GiB used: 374.45 GiB (83.8%) fs: btrfs
dev: /dev/sda2
ID-5: /tempraid size: 200 GiB used: 60.59 GiB (30.3%) fs: btrfs
dev: /dev/sdi2
ID-6: /var/cache size: 446.83 GiB used: 374.45 GiB (83.8%) fs: btrfs
dev: /dev/sda2
ID-7: /var/log size: 446.83 GiB used: 374.45 GiB (83.8%) fs: btrfs
dev: /dev/sda2
ID-8: swap-1 size: 10 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sdf1
ID-9: swap-2 size: 10 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sdj1
ID-10: swap-3 size: 10 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sdi1
ID-11: swap-4 size: 10 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sdk1
ID-12: swap-5 size: 10 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sdg1
Info:
Memory: total: 64 GiB available: 62.69 GiB used: 8.3 GiB (13.2%)
Processes: 571 Uptime: 3h 6m Shell: Sudo inxi: 3.3.41
Those 10 disks are partitioned, with one swap partition each, one small partition contributing to a RAID 0 filesystem for temporary use (not /tmp, since I’m aware that 10-year-old hard drives in a RAID 0 are just asking for trouble). Most of the space goes into a big old RAID 10 array, called bulk, and mounted to /bulk:
❯ sudo btrfs fi show /bulk
Label: 'bulk' uuid: 82006e2d-149a-409d-bc85-7a30e43ea409
Total devices 10 FS bytes used 1.76TiB
devid 1 size 576.17GiB used 378.02GiB path /dev/sdd2
devid 2 size 576.17GiB used 375.55GiB path /dev/sdb2
devid 3 size 576.17GiB used 373.45GiB path /dev/sdc2
devid 4 size 576.17GiB used 372.04GiB path /dev/sde2
devid 5 size 435.76GiB used 294.82GiB path /dev/sdi3
devid 6 size 1.20TiB used 583.56GiB path /dev/sdf3
devid 7 size 202.83GiB used 168.08GiB path /dev/sdg3
devid 8 size 435.76GiB used 296.70GiB path /dev/sdk3
devid 9 size 435.76GiB used 290.97GiB path /dev/sdj3
devid 10 size 1.20TiB used 576.56GiB path /dev/sdh3
Here’s what this looked like in February (kept a note of it because it was running full. Have deleted about 100 GiB since then, so no worries about space shortage)
❯ sudo btrfs fi us /bulk
Overall:
Device size: 6.12TiB
Device allocated: 5.45TiB
Device unallocated: 695.54GiB
Device missing: 0.00B
Device slack: 12.00KiB
Used: 5.43TiB
Free (estimated): 354.55GiB (min: 180.67GiB)
Free (statfs, df): 350.59GiB
Data ratio: 2.00
Metadata ratio: 4.00
Global reserve: 512.00MiB (used: 0.00B)
Multiple profiles: no
Data,RAID10: Size:2.71TiB, Used:2.71TiB (99.76%)
/dev/sdd2 561.02GiB
/dev/sdb2 561.02GiB
/dev/sdc2 563.05GiB
/dev/sde2 563.00GiB
/dev/sdg3 425.07GiB
/dev/sdi3 922.66GiB
/dev/sdk3 194.78GiB
/dev/sdh3 427.71GiB
/dev/sdf3 425.07GiB
/dev/sdj3 916.74GiB
Metadata,RAID1C4: Size:4.01GiB, Used:3.50GiB (87.14%)
/dev/sdd2 4.00GiB
/dev/sdb2 4.01GiB
/dev/sdc2 2.00GiB
/dev/sde2 2.01GiB
/dev/sdi3 3.01GiB
/dev/sdj3 1.01GiB
System,RAID1C4: Size:32.50MiB, Used:688.00KiB (2.07%)
/dev/sdd2 32.25MiB
/dev/sdb2 256.00KiB
/dev/sde2 32.50MiB
/dev/sdi3 32.50MiB
/dev/sdj3 32.50MiB
Unallocated:
/dev/sdd2 11.12GiB
/dev/sdb2 11.13GiB
/dev/sdc2 11.12GiB
/dev/sde2 11.13GiB
/dev/sdg3 10.69GiB
/dev/sdi3 302.82GiB
/dev/sdk3 8.05GiB
/dev/sdh3 8.05GiB
/dev/sdf3 10.69GiB
/dev/sdj3 310.74GiB
What happened
Last week, late at night, the power went off while my PC was running. It was way too late, so I left it off and went to bed.
Yesterday, I noticed a few files missing. Because a large part of the storage is devoted to movies, I assumed that I had moved those to another place and kept going. I also have an automated scrub that runs once per week. That also went through yesterday, without issue. Something looked a bit funny, though, so I also ran a balance (`dusage=50’), for good measure. That was probably a big mistake.
Because today, I looked at some of the other contents, and found that a lot of stuff went missing.
The whole directory structure is exactly as it was, but the files are missing. Not just all the movies and videos I kept, but also a huge part of my Photos (which are backed up, mostly, but could be a lot of work to restore).
Now, it looks like this:
❯ sudo btrfs fi us /bulk
[sudo] Passwort für sascha:
Overall:
Device size: 6.12TiB
Device allocated: 3.62TiB
Device unallocated: 2.50TiB
Device missing: 0.00B
Device slack: 12.00KiB
Used: 3.52TiB
Free (estimated): 1.30TiB (min: 691.50GiB)
Free (statfs, df): 1.25TiB
Data ratio: 2.00
Metadata ratio: 4.00
Global reserve: 49.88MiB (used: 0.00B)
Multiple profiles: no
Data,RAID10: Size:1.80TiB, Used:1.75TiB (97.24%)
<omitted details about which disk has how much or not...>
So … there’s about 2 TiB more space unallocated than there was in February, which makes for about 1 TiB of missing files.
What I’ve tried so far
I’ve unmounted the file system and ran btrfs check
❯ sudo btrfs check /dev/sdg3
Opening filesystem to check...
Checking filesystem on /dev/sdg3
UUID: 82006e2d-149a-409d-bc85-7a30e43ea409
[1/8] checking log skipped (none written)
[2/8] checking root items
[3/8] checking extents
[4/8] checking free space tree
Space key logical 1048576 length 4194304 has no corresponding block group
Space key logical 5242880 length 8388608 has no corresponding block group
Space key logical 13631488 length 8388608 has no corresponding block group
[5/8] checking fs roots
[6/8] checking only csums items (without verifying data)
[7/8] checking root refs
[8/8] checking quota groups skipped (not enabled on this FS)
found 1930731331584 bytes used, error(s) found
total csum bytes: 1883122512
total tree bytes: 2411249664
total fs tree bytes: 337723392
total extent tree bytes: 51675136
btree space waste bytes: 184598204
file data blocks allocated: 1928480935936
referenced 1921613320192
If I use the backup root (option -b), I get almost the same output but some of the numbers are different, and an error message about mismatch in superblock bytes:
❯ sudo btrfs check -b /dev/sdg3
Opening filesystem to check...
Checking filesystem on /dev/sdg3
UUID: 82006e2d-149a-409d-bc85-7a30e43ea409
[1/8] checking log skipped (none written)
[2/8] checking root items
[3/8] checking extents
super bytes used 1930731331584 mismatches actual used 1930731347968
ERROR: errors found in extent allocation tree or chunk allocation
[4/8] checking free space tree
Space key logical 1048576 length 4194304 has no corresponding block group
Space key logical 5242880 length 8388608 has no corresponding block group
Space key logical 13631488 length 8388608 has no corresponding block group
[5/8] checking fs roots
[6/8] checking only csums items (without verifying data)
[7/8] checking root refs
[8/8] checking quota groups skipped (not enabled on this FS)
found 1930731347968 bytes used, error(s) found
total csum bytes: 1883122512
total tree bytes: 2411266048
total fs tree bytes: 337739776
total extent tree bytes: 51675136
btree space waste bytes: 184613010
file data blocks allocated: 1928480935936
referenced 1921613320192
I also tried repeating this with the -s option to use superblock 0, 1 and 2. For 0 and 1, I get identical output, for 2:
❯ sudo btrfs check -s 2 /dev/sdg3
using SB copy 2, bytenr 274877906944
Opening filesystem to check...
ERROR: superblock bytenr 274877906944 is larger than device size 217786089472
ERROR: cannot open file system
I tried various incantations of btrfs restore (with -D option because I currently have nothing to save 1 TiB of restored files to), which list no files at all but mention that they skipped some snapshots, although I don’t think there are any snapshots on the system, at least none that I made explicitly. If I use the -s option to include snapshots, the result is a segmentation fault:
❯ sudo btrfs restore -sD /dev/sdb2 ./btrfs-restore_fake
This is a dry-run, no files are going to be restored
zsh: segmentation fault sudo btrfs restore -sD /dev/sdb2 ./btrfs-restore_fake
…that’s as far as I got.
I have not yet been through all the things I could try with btrfs check, btrfs rescue and btrfs restore.
My Question
The main thing I’d like to get from this forum is some helpful hint about what to try next, because at this point my idea of what went wrong is still somewhat hazy: Maybe btrfs was busy balancing or scrubbing in the background when the power went off, this caused some data to be lost, and the next scrub misinterpreted what it found and restored RAID 10 consistency by picking the wrong version of what it found.
What I don’t know is:
- Whether that is actually plausible or I’m just guessing wrong.
- How I can get as much data back as possible without trying every thing that might just work, in random order. I’m sure there’s a more structured approach that I’m missing
- How I could avoid this scenario in the future (without increasing redundancy even further). I have four copies of metadata and system data, for crying out loud. btrfs should have been able to know what’s correct and what isn’t. If that’s not doing it, what is?
