Recently I’ve been fortunate enough to get my hands on an additional set of 3x 4TB disks, which I’ll be adding to my existing 3x 4TB mdadm/lvm2 array. However, first I need to decommission my 3 x 2TB BTRFS array, and move the stored data to mdadm/lvm/ext4
btrfs was configured in a controversially dangerous RAID5 configuration, so the job was to rebalance the entire filesystem as RAID1, remove a drive, allocate it to mdadm/lvm2/ext4, and then shuffle the data across, and then delete the remaining 2 drive btrfs array. Due to the amount of data being stored, there was not enough space to permit a rebalance directly to RAID1
First port of call was to remove one drive from the btrfs array, replace it with the larger disk, rebalance, scrub, and repeat for the other two disks.
Over the course of the three disks, it would be
sudo btrfs replace start 1 /dev/sdg /mnt/foo -f
sudo btrfs replace start 2 /dev/sdh /mnt/foo -f
sudo btrfs replace start 3 /dev/sdi /mnt/foo -f
Interspersed with instances of
sudo btrfs balance start /mnt/foo
sudo btrfs scrub start /mnt/foo
Before I converted to RAID1, I needed to rebalance all the data as raid1, but that required resizing the btrfs filesystem to take advantage of the larger disks.
The one thing that caught me out was the subsequent array resize. Many pieces of documentation just refer to this
sudo btrfs filesystem resize max /mnt/foo
But this will *ONLY* apply to the first disk in the array.
What is really needed is
sudo btrfs filesystem resize 1:max /mnt/foo
sudo btrfs filesystem resize 2:max /mnt/foo
sudo btrfs filesystem resize 3:max /mnt/foo
This will instruct btrfs to use all the slack space on each disk, thus permitting in this case a conversion to raid1
sudo btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt/foo
And then the subsequent removal of a disk with
sudo btrfs device delete /dev/sdf /mnt/foo