使用 btrfs 恢复磁盘

使用 btrfs 恢复磁盘

当我尝试在同一台 PC 上的 SSD 上安装 Windows 后,我需要帮助恢复 BTRFS 所在的 HDD。因此,我的 PC 有 3 个磁盘:

  • BTRFS 下装有 Fedora 的 SSD - /dev/sda{x}
  • 没有任何 FS 的 SSD - /dev/sdb
  • HDD 作为 BTRFS 下的文件存储 - /dev/sdc。

我尝试在 /dev/sdb 上安装 Windows,以便在同一台 PC 上安装 2 个操作系统。但由于某些不明原因,Windows 安装以某种方式更改了 /dev/sdc 上的 FS

➜  ~ sudo lsblk /dev/sdc   
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sdc      8:32   0  1,8T  0 disk 
└─sdc1   8:33   0  100M  0 part

➜  ~ sudo btrfs fi show /dev/sdc
Label: 'Disk 2TB'  uuid: 24075f5b-eb67-45d8-a9cd-5fe6b9d11248
    Total devices 1 FS bytes used 1.45TiB
    devid    1 size 1.82TiB used 1.46TiB path /dev/sdc

磁盘无法安装,因为

➜  ~ sudo mount /dev/sdc /mnt/disk_2tb 
mount: /mnt/disk_2tb: wrong fs type, bad option, bad superblock on /dev/sdc, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.
➜  ~ dmesg| grep sdc
[    1.983864] sd 4:0:0:0: [sdc] 3907029168 512-byte logical blocks: (2.00 TB/1.82 TiB)
[    1.983868] sd 4:0:0:0: [sdc] 4096-byte physical blocks
[    1.983874] sd 4:0:0:0: [sdc] Write Protect is off
[    1.983876] sd 4:0:0:0: [sdc] Mode Sense: 00 3a 00 00
[    1.983885] sd 4:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    1.983896] sd 4:0:0:0: [sdc] Preferred minimum I/O size 4096 bytes
[    2.024803]  sdc: sdc1
[    2.024940] sd 4:0:0:0: [sdc] Attached SCSI disk
[    3.196935] BTRFS: device label Disk 2TB devid 1 transid 5113 /dev/sdc scanned by systemd-udevd (491)
[  109.407061]  sdc: sdc1
[  183.250214]  sdc: sdc1
[  220.103191]  sdc: sdc1
[  713.817340]  sdc: sdc1
[  752.095854]  sdc: sdc1
[ 4253.223636]  sdc: sdc1
[ 4253.244072] BTRFS: device label Disk 2TB devid 1 transid 5113 /dev/sdc scanned by systemd-udevd (17293)
[ 4260.709988]  sdc: sdc1
[ 4438.692603]  sdc: sdc1
[ 4551.237692] BTRFS info (device sdc): using free space tree
[ 4551.237697] BTRFS info (device sdc): has skinny extents
[ 4551.238345] BTRFS error (device sdc): bad tree block start, want 27230208 have 5227060755056173072
[ 4551.238460] BTRFS error (device sdc): bad tree block start, want 27230208 have 0
[ 4551.238466] BTRFS error (device sdc): failed to read chunk root
[ 4551.239223] BTRFS error (device sdc): open_ctree failed

根据btrfs rescue super-recover磁盘有坏的超级

➜  ~ sudo btrfs rescue super-recover -v /dev/sdc
All Devices:
    Device: id = 1, name = /dev/sdc

Before Recovering:
    [All good supers]:
        device name = /dev/sdc
        superblock bytenr = 65536

        device name = /dev/sdc
        superblock bytenr = 274877906944

    [All bad supers]:
        device name = /dev/sdc
        superblock bytenr = 67108864


Make sure this is a btrfs disk otherwise the tool will destroy other fs, Are you sure? [y/N]: y
checksum verify failed on 27230208 wanted 0x902be40a found 0x55ee4508
checksum verify failed on 27230208 wanted 0x00000000 found 0xb6bde3e4
ERROR: cannot read chunk root
Failed to recover bad superblocks

btrfs-find-root还有、btrfs-select-super和的输出btrfs check

➜  ~ sudo btrfs-find-root /dev/sdc
WARNING: cannot read chunk root, continue anyway
Superblock thinks the generation is 5113
Superblock thinks the level is 0

➜  ~ sudo btrfs-select-super -s 1 /dev/sdc
No valid Btrfs found on /dev/sdc
Open ctree failed

➜  ~ sudo btrfs check --repair /dev/sdc
enabling repair mode
WARNING:

    Do not use --repair unless you are advised to do so by a developer
    or an experienced user, and then only after having accepted that no
    fsck can successfully repair all types of filesystem corruption. Eg.
    some software or hardware bugs can fatally damage a volume.
    The operation will start in 10 seconds.
    Use Ctrl-C to stop it.
10 9 8 7 6 5 4 3 2 1
Starting repair.
Opening filesystem to check...
checksum verify failed on 27230208 wanted 0x902be40a found 0x55ee4508
checksum verify failed on 27230208 wanted 0x00000000 found 0xb6bde3e4
checksum verify failed on 27230208 wanted 0x902be40a found 0x55ee4508
bad tree block 27230208, bytenr mismatch, want=27230208, have=5227060755056173072
ERROR: cannot read chunk root
ERROR: cannot open file system

日志档案btrfs rescue chunk-recover执行。

有什么想法可以解决此类错误吗?

相关内容