Converting single-device BTRFS to dual-device BTRFS RAID1 on OpenSUSE Tumbleweed
How to convert a single-disk BTRFS filesystem to a dual-disk BTRFS RAID1 array on OpenSUSE Tumbleweed.
I have two disks, disk one is 109.29GiB in size and disk two is 223.57GiB in size. They are both Solid State Drives.
When using two disks, one smaller than the other, the size of the RAID1 array will be limited to the size of the smallest disk. It is recommended to have two disks similar in size.
Currently disk one is the only disk that BTRFS knows about. To change this I need to create a BTRFS filesystem on the second disk and add it to the BTRFS pool, then convert the pool to RAID1 mode.
If you intend to boot off the second disk (which is recommended in case the first disk fails), you need to skip the following section and manually create the boot and BTRFS partitions on the second disk.
Add the device or partition
In this example:
/dev/sdais the device name of the first disk./dev/sdbis the device name of the second disk.
1
$ sudo btrfs device add -f /dev/sdb /
I need to specify -f so that BTRFS will automatically create the filesystem on the second disk (which will erase all data on it).
If you are using a BTRFS formatted partition as the second device, make sure to instead use this command without the
-fflag:
1 $ sudo btrfs device add /dev/sdb<partnum> /
Verify that the disk / partition has been added to the pool
I have added the second disk to BTRFS and to verify that it knows about it I can run $ sudo btrfs filesystem show which will return:
1
2
3
4
Label: none uuid: a9e30ccf-329b-4483-ab4a-57065f38c808
Total devices 2 FS bytes used 78.66GiB
devid 1 size 109.29GiB used 81.03GiB path /dev/sda2
devid 2 size 223.57GiB used 0GiB path /dev/sdb
Convert pool data and metadata into BTRFS RAID1
RAID1 is not configured yet and we need to balance the data and metadata between both disks.
To convert the disks to RAID1 we need to run this command:
1
$ sudo btrfs balance start -mconvert=raid1 -dconvert=raid1 /
This will balance the metadata and data between both disks otherwise known as mirroring. It will take a while (for me it took around half an hour).
After the balance operation is completed, you can run $ sudo btrfs fi df / to verify that BTRFS is running in RAID1 mode, it should return:
1
2
3
4
Data, RAID1: total=78.00GiB, used=76.61GiB
System, RAID1: total=32.00MiB, used=16.00KiB
Metadata, RAID1: total=3.00GiB, used=2.05GiB
GlobalReserve, single: total=175.19MiB, used=0.00B
