最近,我更换了两个 Btrfs RAID-1 文件系统上的设备,因为需要更换磁盘。
我是这样做的:
mount -o noatime,degraded /dev/sda3 /mnt/tmp
btrfs fi show /dev/sda3
btrfs replace start -B 1 /dev/nvme0n1p3 /mnt/tmp
btrfs replace status /mnt/tmp
btrfs fi show /dev/sda3
btrfs fi show /mnt/tmp
btrfs scrub start -B /mnt/tmp
mount -o noatime /dev/sda3 /mnt/tmp
ls /mnt/tmp
btrfs fi show /mnt/tmp
umount /mnt/tmp
这意味着:
- 我安装了该设备,因为
btrfs replace
似乎只支持替换已安装文件系统上的设备 - 我检查了
btrfs fi show
缺少什么设备 ID(1
在本例中) - 因此,我
1
用nvme0n1p3
新磁盘上的设备替换了丢失的设备 - 最后的表演看起来不错,磨砂膏也没有抱怨
- 程序运行正常后卸载并安装(无降级)
- 这些命令或内核日志中没有报告任何错误
但是,在我删除旧的腿(即/dev/sda3)后,文件系统无法再安装:
mount -o noatime,degraded /dev/nvme0n1p3 /mnt/tmp
mount: /mnt/tmp: wrong fs type, bad option, bad superblock on /dev/nvme0n1p3, missing codepage or helper program, or other error.
失败并产生:
Dec 22 09:41:34 BTRFS info (device nvme0n1p3): allowing degraded mounts
Dec 22 09:41:34 BTRFS info (device nvme0n1p3): disk space caching is enabled
Dec 22 09:41:34 BTRFS info (device nvme0n1p3): has skinny extents
Dec 22 09:41:34 BTRFS warning (device nvme0n1p3): devid 2 uuid f9c9c081-0fdc-4b61-8329-c1addb51e3fe is missing
Dec 22 09:41:34 BTRFS error (device nvme0n1p3): failed to read chunk root
Dec 22 09:41:34 BTRFS error (device nvme0n1p3): open_ctree failed
所以我的期望是:
- 一条
btrfs replace
命令足以替换 RAID-1 btrfs 文件系统上丢失的设备 - 特别是,
btrfs replace
会将剩余的所有数据/元数据复制到新添加的设备
由于这不起作用,我不再确定 a 是否btrfs replace
总是足够的。
也许之后是否btrfs replace
需要明确的平衡?
例如通过这样的事情?
btrfs balance start -dconvert=raid1,soft -mconvert=raid1,soft /mnt/tmp
附加信息:
- 因此,总体目标是替换 RAID-1 btrfs 文件系统的两条腿,即分两步进行替换 - 首先是左腿,然后是右腿
- 在 Fedora 33 上完成替换(内核 5.8.18-300.fc33.x86_64 和 btrfs-progs-5.7-5.fc33.x86_64)
- Btrfs 文件系统是在 Ubuntu 20.04 上创建的
btrfs rescue chunk-recover
没有帮助
现btrfs fi show
报道如下:
btrfs fi show /dev/nvme0n1p3
warning, device 2 is missing
warning, device 2 is missing
bad tree block 934674432, bytenr mismatch, want=934674432, have=0
ERROR: cannot read chunk root
Label: none uuid: 1c1a03db-38c2-4b08-a2ec-47d200f98b0a
Total devices 2 FS bytes used 196.62MiB
devid 1 size 1.00GiB used 758.38MiB path /dev/nvme0n1p3
*** Some devices missing
我不知道为什么警告重复两次。
第二个例子
在同一系统上,替换另一个 Btrfs RAID-1 文件系统中丢失的磁盘也会以类似的方式失败。
更换程序:
mount -o noatime,degraded /dev/mapper/new-root-1 /mnt/tmp
btrfs fi show /mnt/tmp
btrfs replace start -B 1 /dev/mapper/new-root-0 /mnt/tmp
journalctl -fk
btrfs fi show /mnt/tmp
btrfs scrub start -B /mnt/tmp
umount /mnt/tmp
移除另一条腿后安装失败:
mount -o noatime,degraded /dev/mapper/new-root-0 /mnt/tmp
mount: /mnt/tmp: wrong fs type, bad option, bad superblock on /dev/mapper/new-root-0, missing codepage or helper program, or other error.
安装期间记录的错误:
Dec 22 09:57:12 BTRFS info (device dm-1): allowing degraded mounts
Dec 22 09:57:12 sos.lru.li kernel: BTRFS info (device dm-1): disk space caching is enabled
Dec 22 09:57:12 BTRFS info (device dm-1): has skinny extents
Dec 22 09:57:12 BTRFS warning (device dm-1): devid 2 uuid 3093e508-17e0-4f5c-af13-642954e6fd9b is missing
Dec 22 09:57:12 BTRFS warning (device dm-1): devid 2 uuid 3093e508-17e0-4f5c-af13-642954e6fd9b is missing
Dec 22 09:57:12 BTRFS info (device dm-1): bdev (efault) errs: wr 0, rd 8, flush 0, corrupt 0, gen 0
Dec 22 09:57:12 BTRFS warning (device dm-1): chunk 69823627264 missing 1 devices, max tolerance is 0 for writable mount
Dec 22 09:57:12 BTRFS warning (device dm-1): writable mount is not allowed due to too many missing devices
Dec 22 09:57:12 BTRFS error (device dm-1): open_ctree failed
缺少设备警告在这里重复四次:
btrfs fi show /dev/mapper/new-root-0
warning, device 2 is missing
warning, device 2 is missing
warning, device 2 is missing
warning, device 2 is missing
Label: none uuid: 3e861d70-9a98-402d-8bbc-ddec6f869433
Total devices 2 FS bytes used 62.81GiB
devid 1 size 231.67GiB used 65.01GiB path /dev/mapper/new-root-0
*** Some devices missing
答案1
在安装降级时写入的任何数据最终可能会以单个或双配置文件存储。平衡运行可确保此类数据也得到镜像。