I have a USB-HDD of 2TB size with metadata DUP . After an unclean shutdown I now cannot mount it anymore.

My question is what (possibly destructive) rescue operation to try next after having backuped the corrupted disk elsewhere first. I am thinking of `btrfs check --init-extent-tree` or `btrfs rescue chunk-recover` Unfortunately I'm not well versed enough in btrfs to know what precisely that would do, or if it would help at all or just make it worse.

I also don't know how to use that less corrupted DUPlicated version of the FStree to get the disk to be mountable again, which, if I understand it correctly, would open up scrub and balance as other possible repair options.


Thanks in advance for your help and awesome filesystem.
Cheers!


Here's what I've done so far:

$ uname -a
Linux Fabian-openSUSE 5.11.12-1-default #1 SMP Wed Apr 7 17:30:21 UTC 2021 (92a542e) x86_64 x86_64 x86_64 GNU/Linux

$ sudo btrfs --version
[sudo] password for root:
btrfs-progs v5.11

$ sudo btrfs fi show
Label: 'BTRFS-Archive'  uuid: 2566e7c1-1e0f-40eb-ab68-914e5c346884
        Total devices 1 FS bytes used 1.60TiB
        devid    1 size 1.82TiB used 1.61TiB path /dev/sdb2

dmesg outputs the following with `mount -o rescue=all,ro`
[23079.810710] BTRFS info (device sdb2): enabling all of the rescue options
[23079.810713] BTRFS info (device sdb2): ignoring data csums
[23079.810713] BTRFS info (device sdb2): ignoring bad roots
[23079.810715] BTRFS info (device sdb2): disabling log replay at mount time
[23079.810716] BTRFS info (device sdb2): disk space caching is enabled
[23079.810717] BTRFS info (device sdb2): has skinny extents
[23079.925185] BTRFS info (device sdb2): bdev /dev/sdb2 errs: wr 0, rd 0, flush 0, corrupt 51, gen 0 [23080.156357] BTRFS critical (device sdb2): corrupt leaf: root=1 block=449881636864 slot=18 ino=2276, invalid inode generation: has 13167 expect (0, 13165] [23080.156377] BTRFS error (device sdb2): block=449881636864 read time tree block corruption detected [23080.169840] BTRFS critical (device sdb2): corrupt leaf: root=1 block=449881636864 slot=18 ino=2276, invalid inode generation: has 13167 expect (0, 13165] [23080.169859] BTRFS error (device sdb2): block=449881636864 read time tree block corruption detected
[23080.169891] BTRFS error (device sdb2): failed to read block groups: -5
[23080.173682] BTRFS error (device sdb2): open_ctree failed

$ sudo btrfs check /dev/sdb2
Opening filesystem to check...
parent transid verify failed on 449881636864 wanted 12615 found 13172
parent transid verify failed on 449881636864 wanted 12615 found 13172
parent transid verify failed on 449881636864 wanted 12615 found 13172
Ignoring transid failure
leaf parent key incorrect 449881636864
ERROR: failed to read block groups: Operation not permitted
ERROR: cannot open file system


I have already run `btrfs rescue super-recover` and `btrfs rescue zero-log` without success.


Luckily I have set up that disk with metadata DUP so I was able to do

$ sudo btrfs check -r 30408704 -s1 -p /dev/sdb2

and

$ sudo btrfs restore -D -t 30408704 -i /dev/sdb2 1TB-Platte2/

After finding that (stripe 1) offset via

$ sudo btrfs inspect-internal dump-super -f /dev/sdb2
superblock: bytenr=65536, device=/dev/sdb2
---------------------------------------------------------
csum_type               0 (crc32c)
csum_size               4
csum                    0x236347b4 [match]
bytenr                  65536
flags                   0x1
                        ( WRITTEN )
magic                   _BHRfS_M [match]
fsid                    2566e7c1-1e0f-40eb-ab68-914e5c346884
metadata_uuid           2566e7c1-1e0f-40eb-ab68-914e5c346884
label                   BTRFS-Archive
generation              13164
root                    2271131025408
sys_array_size          129
chunk_root_generation   13160
root_level              1
chunk_root              22036480
chunk_root_level        1
log_root                0
log_root_transid        0
log_root_level          0
total_bytes             2000188080128
bytes_used              1759527608320
sectorsize              4096
nodesize                16384
leafsize (deprecated)   16384
stripesize              4096
root_dir                6
num_devices             1
compat_flags            0x0
compat_ro_flags         0x0
incompat_flags          0x179
                        ( MIXED_BACKREF |
                          COMPRESS_LZO |
                          COMPRESS_ZSTD |
                          BIG_METADATA |
                          EXTENDED_IREF |
                          SKINNY_METADATA )
cache_generation        13164
uuid_tree_generation    13164
dev_item.uuid           5dda7f3a-edeb-45ed-8a94-d1c11bc74400
dev_item.fsid           2566e7c1-1e0f-40eb-ab68-914e5c346884 [match]
dev_item.type           0
dev_item.total_bytes    2000188080128
dev_item.bytes_used     1765256724480
dev_item.io_align       4096
dev_item.io_width       4096
dev_item.sector_size    4096
dev_item.devid          1
dev_item.dev_group      0
dev_item.seek_speed     0
dev_item.bandwidth      0
dev_item.generation     0
sys_chunk_array[2048]:
        item 0 key (FIRST_CHUNK_TREE CHUNK_ITEM 22020096)
                length 8388608 owner 2 stripe_len 65536 type SYSTEM|DUP
                io_align 65536 io_width 65536 sector_size 4096
                num_stripes 2 sub_stripes 0
                        stripe 0 devid 1 offset 22020096
                        dev_uuid 5dda7f3a-edeb-45ed-8a94-d1c11bc74400
                        stripe 1 devid 1 offset 30408704
                        dev_uuid 5dda7f3a-edeb-45ed-8a94-d1c11bc74400
backup_roots[4]:
        backup 0:
                backup_tree_root:       2271131025408   gen: 13164      level: 1                 backup_chunk_root:      22036480        gen: 13160      level: 1                 backup_extent_root:     2271131041792   gen: 13164      level: 2                 backup_fs_root:         2271132139520   gen: 13163      level: 2                 backup_dev_root:        2271131910144   gen: 13164      level: 1                 backup_csum_root:       2271144263680   gen: 13164      level: 2
                backup_total_bytes:     2000188080128
                backup_bytes_used:      1759527608320
                backup_num_devices:     1

        backup 1:
                backup_tree_root:       2271522717696   gen: 13161      level: 1                 backup_chunk_root:      22036480        gen: 13160      level: 1                 backup_extent_root:     2271427756032   gen: 13161      level: 2                 backup_fs_root:         2271659212800   gen: 13162      level: 2                 backup_dev_root:        2271845613568   gen: 13160      level: 1                 backup_csum_root:       2271115018240   gen: 13161      level: 2
                backup_total_bytes:     2000188080128
                backup_bytes_used:      1759125020672
                backup_num_devices:     1

        backup 2:
                backup_tree_root:       2271131172864   gen: 13162      level: 1                 backup_chunk_root:      22036480        gen: 13160      level: 1                 backup_extent_root:     2271126110208   gen: 13162      level: 2                 backup_fs_root:         2271659212800   gen: 13162      level: 2                 backup_dev_root:        2271845613568   gen: 13160      level: 1                 backup_csum_root:       2272123355136   gen: 13162      level: 2
                backup_total_bytes:     2000188080128
                backup_bytes_used:      1759290830848
                backup_num_devices:     1

        backup 3:
                backup_tree_root:       2271143755776   gen: 13163      level: 1                 backup_chunk_root:      22036480        gen: 13160      level: 1                 backup_extent_root:     2271141412864   gen: 13163      level: 2                 backup_fs_root:         2271132139520   gen: 13163      level: 2                 backup_dev_root:        2271845613568   gen: 13160      level: 1                 backup_csum_root:       2271132188672   gen: 13163      level: 2
                backup_total_bytes:     2000188080128
                backup_bytes_used:      1759527608320
                backup_num_devices:     1


Reply via email to