convert a single drive btrfs disk into a RAID1 with a second disk

I am running btrfs 4.15.1 on a fresh ubuntu 18.04 server. I have a small hardrive which for / and a large disk for documents served to my colleagues in our office via samba. That data drive is used entirely for this, has been created by mkfs.btrfs /deb/sdb/ and is mounted to /mnt/data/.

Further down the road I want to add a second harddisk and convert the singledrive data disk into a RAID1 (data & metadata I guess). Would the commands below achieve that goal?

btrfs device add /dev/sdc /mnt/data
btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt

would I have to do a mkfs.btrfs /dev/sdc/ before adding the new harddrive to the system?


Solution 1:

Btrfs will create the filesystem for you. Before you add the device, it should look like this:

$ sudo btrfs filesystem show
  Label: none  uuid: 14736aed-faa3-4f03-819e-24369e9bb34f
           Total devices 1 FS bytes used 384.00KiB
           devid    1 size 20.00GiB used 2.02GiB path /dev/sdb

When adding the device (if there is a existing partition table you need the -f option, it will overwrite the partition table) it will look like this:

$ sudo btrfs device add -f /dev/sdc /mnt/data
$ sudo btrfs filesystem show
  Label: none  uuid: 14736aed-faa3-4f03-819e-24369e9bb34f
          Total devices 2 FS bytes used 384.00KiB
          devid    1 size 20.00GiB used 2.02GiB path /dev/sdb
          devid    2 size 20.00GiB used 0.00B path /dev/sdc

Then start the balancing process:

$ sudo btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt/data
  Done, had to relocate 4 out of 4 chunks