我今天必须更换 btrfs RAID1 设备。这是操作前的文件系统状态:
$ btrfs filesystem show /mnt
Label: none uuid: b19e1a48-a25b-4f63-941d-c009949a5d51
Total devices 2 FS bytes used 2.11TiB
devid 1 size 0 used 0 path MISSING
devid 2 size 5.46TiB used 2.17TiB path /dev/mapper/datadungeon
然后我就跑了btrfs replace start -r 1 /dev/mapper/eternalepoch /mnt
。由于阅读了错误的部分,我-r
错误地放置了 ,但手册页向我表明应该没问题。这是开始操作后不久的文件系统:
$ btrfs filesystem show /mnt
Label: none uuid: b19e1a48-a25b-4f63-941d-c009949a5d51
Total devices 3 FS bytes used 2.11TiB
devid 0 size 2.73TiB used 2.17TiB path /dev/mapper/eternalepoch
devid 1 size 0 used 0 path MISSING
devid 2 size 5.46TiB used 2.18TiB path /dev/mapper/datadungeon
这是操作完成后的文件系统(我也做了一个btrfs filesystem resize 1:max /mnt
):
$ btrfs filesystem show /mnt
Label: none uuid: b19e1a48-a25b-4f63-941d-c009949a5d51
Total devices 2 FS bytes used 2.11TiB
devid 1 size 5.46TiB used 2.17TiB path /dev/mapper/eternalepoch
devid 2 size 5.46TiB used 4.35TiB path /dev/mapper/datadungeon
我du -sch
在安装了的设备 2 的根目录上运行-o degraded
(希望单独提供该驱动器的结果),它给了我 2.17TB,正如预期的那样。所以,我的问题是:为什么报告的尺寸增加了一倍,我该如何取回它!?就像它克隆了自己一样。平衡操作会起作用还是只会使其他设备的大小增加一倍?
答案1
因此,在偶尔检查filesystem usage
(device usage
给出了类似的信息filesystem show
)后,我发现2.17TB实际上是很少的数据:
$ btrfs filesystem usage /mnt
Overall:
Device size: 10.92TiB
Device allocated: 6.52TiB
Device unallocated: 4.39TiB
Device missing: 0.00B
Device slack: 0.00B
Used: 4.22TiB
Free (estimated): 4.45TiB (min: 3.72TiB)
Free (statfs, df): 1.17TiB
Data ratio: 1.50
Metadata ratio: 1.50
Global reserve: 512.00MiB (used: 0.00B)
Multiple profiles: yes (data, metadata, system)
Data,single: Size:2.17TiB, Used:256.00KiB (0.00%)
/dev/mapper/datadungeon 2.17TiB
Data,RAID1: Size:2.17TiB, Used:2.10TiB (97.22%)
/dev/mapper/eternalepoch 2.17TiB
/dev/mapper/datadungeon 2.17TiB
Metadata,single: Size:10.00GiB, Used:112.00KiB (0.00%)
/dev/mapper/datadungeon 10.00GiB
Metadata,RAID1: Size:10.00GiB, Used:3.05GiB (30.50%)
/dev/mapper/eternalepoch 10.00GiB
/dev/mapper/datadungeon 10.00GiB
System,single: Size:32.00MiB, Used:240.00KiB (0.73%)
/dev/mapper/datadungeon 32.00MiB
System,RAID1: Size:32.00MiB, Used:336.00KiB (1.03%)
/dev/mapper/eternalepoch 32.00MiB
/dev/mapper/datadungeon 32.00MiB
Unallocated:
/dev/mapper/eternalepoch 3.28TiB
/dev/mapper/datadungeon 1.11TiB
所以我最终只是做了一个平衡btrfs balance start -dprofiles=single,convert=raid1,soft -mprofiles=single,convert=raid1,soft /mnt
(我认为在这种情况下soft和profiles=single是多余的)。几分钟后我得到:
btrfs filesystem show /data
Label: none uuid: b19e1a48-a25b-4f63-941d-c009949a5d51
Total devices 2 FS bytes used 2.11TiB
devid 1 size 5.46TiB used 4.35TiB path /dev/mapper/eternalepoch
devid 2 size 5.46TiB used 4.35TiB path /dev/mapper/datadungeon
但是!,文件系统使用量实际上只有 2.10TB:
Data,RAID1: Size:4.33TiB, Used:2.10TiB (48.61%)
/dev/mapper/eternalepoch 4.33TiB
/dev/mapper/datadungeon 4.33TiB
所以我想在运行替换命令之前,一些数据刚刚写入第一个磁盘,btrfs 由于某种原因立即分配了 2.17TB,这只是一个非问题,导致我缺乏对 btrfs 输出的了解(具体来说,有时used
是没有实际使用,只是分配)。