Btrfs 不采用多设备

Btrfs 不采用多设备

我最近向现有的 Btrfs 文件系统添加了一个设备,但它没有报告新设备甚至没有为数据分配任何空间。看一下:

在我开始之前:

# btrfs fi show /
Label: 'LINUX'  uuid: f0b4d012-91d8-43bd-90b5-e398a012ccff
    Total devices 1 FS bytes used 126.72GiB
    devid    1 size 272.40GiB used 128.03GiB path /dev/sda3
# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 273.4G  0 disk 
├─sda1   8:1    0     1M  0 part 
├─sda2   8:2    0     1G  0 part /boot
└─sda3   8:3    0 272.4G  0 part /pool
sdb      8:16   0  68.3G  0 disk 

所以现在我想补充一点/dev/sdb

# btrfs device add /dev/sdb /
# btrfs balance start --full-balance /

< 大约一个小时后... >

# btrfs fi usage /
Overall:
    Device size:         340.73GiB
    Device allocated:    128.03GiB
    Device unallocated:  212.70GiB
    Device missing:          0.00B
    Used:                126.68GiB
    Free (estimated):    213.10GiB  (min: 213.10GiB)
    Data ratio:               1.00
    Metadata ratio:           1.00
    Global reserve:      338.14MiB  (used: 0.00B)

Data,single: Size:126.00GiB, Used:125.60GiB
   /dev/sda3     126.00GiB

Metadata,single: Size:2.00GiB, Used:1.08GiB
   /dev/sda3       2.00GiB

System,single: Size:32.00MiB, Used:16.00KiB
   /dev/sda3      32.00MiB

Unallocated:
   /dev/sda3     144.37GiB
   /dev/sdb       68.33GiB

嗯,我想应该可以做到这一点,让我们尝试一下:

# btrfs balance start -dconvert=single -mconvert=raid1 /

< 大约一个小时后... >

# btrfs fi show /
Label: 'LINUX'  uuid: f0b4d012-91d8-43bd-90b5-e398a012ccff
    Total devices 2 FS bytes used 126.72GiB
    devid    1 size 272.40GiB used 128.03GiB path /dev/sda3
    devid    2 size 68.33GiB used 2.03GiB path /dev/sdb
# btrfs fi usage /
Overall:
    Device size:         340.73GiB
    Device allocated:    130.06GiB
    Device unallocated:  210.67GiB
    Device missing:          0.00B
    Used:                127.80GiB
    Free (estimated):    211.03GiB  (min: 105.69GiB)
    Data ratio:               1.00
    Metadata ratio:           2.00
    Global reserve:      338.47MiB  (used: 0.00B)

Data,single: Size:126.00GiB, Used:125.64GiB
   /dev/sda3    126.00GiB

Metadata,RAID1: Size:2.00GiB, Used:1.08GiB
   /dev/sda3      2.00GiB
   /dev/sdb       2.00GiB

System,RAID1: Size:32.00MiB, Used:16.00KiB
   /dev/sda3     32.00MiB
   /dev/sdb      32.00MiB

Unallocated:
   /dev/sda3    144.37GiB
   /dev/sdb      66.30GiB

有没有搞错?

内核在平衡过程中说过什么吗? 只是一大堆这样的:

Feb 13 21:55:06 localhost kernel: BTRFS info (device sda3): found 7541 extents
Feb 13 21:55:06 localhost kernel: BTRFS info (device sda3): relocating block group 621927202816 f
Feb 13 21:55:18 localhost kernel: BTRFS info (device sda3): found 7020 extents
Feb 13 21:55:28 localhost kernel: BTRFS info (device sda3): found 7020 extents
Feb 13 21:55:28 localhost kernel: BTRFS info (device sda3): relocating block group 620853460992 f
Feb 13 21:55:39 localhost kernel: BTRFS info (device sda3): found 2540 extents
Feb 13 21:55:48 localhost kernel: BTRFS info (device sda3): found 2540 extents
Feb 13 21:55:48 localhost kernel: BTRFS info (device sda3): relocating block group 619779719168 f
Feb 13 21:55:58 localhost kernel: BTRFS info (device sda3): found 3971 extents

答案1

实际上,-dconvert=single它会在设备之间平衡数据(正如您所期望的那样),而不会对其进行条带化。但文档说分配是“线性的”。我不太明白这是什么意思,但可能是只有当一个设备已满时,才会使用另一个设备。

如果你访问此页面:https://btrfs.wiki.kernel.org/index.php/Using_Btrfs_with_Multiple_Devices#Filesystem_creation,你可以读一下这个……

# Use full capacity of multiple drives with different sizes (metadata mirrored, data not mirrored and not striped)
mkfs.btrfs -d single /dev/sdb /dev/sdc

(重点是“满负荷”)

就我而言,我有两台具有此配置的 PC(单数据、raid1 元数据)。第一台 PC 使用 3 个驱动器存储数据,而第二台 PC 仅使用一个驱动器存储数据,使用 3 个驱动器存储元数据。我仍然不知道为什么,但我希望将来会记录下来。

相关内容