Converting single-device BTRFS to dual-device BTRFS RAID1 on OpenSUSE Tumbleweed

Yusef Aslam - 08 Oct 2024

Tags: btrfs,linux,opensuse

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.

Currently disk one is the only disk that BTRFS knows about. To change this I need to add the second disk with this command which will create a BTRFS filesystem on the second disk and also add it to BTRFS.

  • /dev/sda is the device name of the first disk.
  • /dev/sdb is 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).

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

Currently there is not any RAID configured and the second disk’s space is added onto the first disk. 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

Regenerated at : November 20, 2024 - 13:38:24 GMT