I have a little home server that I use to store media, email, as a NAS, and as backup storage device. One of the disks was getting quite full, so I decided to add a disk in RAID-0 mode (striped). Luckily this disk was formatted with btrfs, which supports various multiple disk architectures.
The disk that runs full is /dev/sdb
, a 2TB Samsung disk mounted on /mnt/SAMS2000
.
I bought another 2TB disk, this time a Western Digital.
After physically connecting the disk it showed up as /dev/sdc
.
The new disk can be added to the existing one as follows:
# btrfs device add /dev/sdc /mnt/SAMS2000
No unmounting, partitioning or formatting required.
I had not researched it, but the WD and the Samsung disk turn out to have exactly the same size and geometry:
# fdisk -l /dev/sdb
Disk /dev/sdb: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: ST2000LM003 HN-M
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5829b0b5
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 3907029167 3907027120 1.8T 83 Linux
# fdisk -l /dev/sdc
Disk /dev/sdc: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: WDC WD20SPZX-22U
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Such luck!
It is recommended to use the full disk. The Samsung disk does have a partition table in it, maybe I will remove that at some time, but it would require to move all the contents off it, so I will leave that be for now.
After adding the new disk, we have something called JBOD, just a bunch of disks, not a RAID-0 set, not striped:
# btrfs filesystem show /mnt/SAMS2000
Label: 'SAMS2000' uuid: 8df7191d-5f3f-4c74-92b2-3b4ea02a69aa
Total devices 2 FS bytes used 1.42TiB
devid 1 size 1.82TiB used 1.42TiB path /dev/sdb1
devid 2 size 1.82TiB used 0.00 path /dev/sdc
It shows that the newly added disk is not used at all yet. Both disks now have the same label, and the setup of the old Samsung disk:
# btrfs filesystem df /mnt/SAMS2000
Data, single: total=1.47TiB, used=1.42TiB
System, dup: total=32.00MiB, used=144.00KiB
Metadata, dup: total=2.00GiB, used=1.52GiB
GlobalReserve, single: total=512.00MiB, used=0.00B
Single for data means that the data is stored once on disk; dup for the metadata means that the metadata is stored twice on the same disk. Now that we are making a RAID set with two disks, we'd want the metadata still stored twice, but on each disk: RAID-1. The data should be still stored once, but striped over the two disks: RAID-0.
Converting the JBOD into a RAID set can take a long time, depending on how full the disk is:
# btrfs balance start -dconvert=raid0 -mconvert=raid1 /mnt/SAMS2000
Done, had to relocate 756 out of 756 chunks
# btrfs filesystem show /mnt/SAMS2000
Label: 'SAMS2000' uuid: 8df7191d-5f3f-4c74-92b2-3b4ea02a69aa
Total devices 2 FS bytes used 1.42TiB
devid 1 size 1.82TiB used 764.03GiB path /dev/sdb1
devid 2 size 1.82TiB used 764.03GiB path /dev/sdc
# btrfs filesystem df /mnt/SAMS2000
Data, RAID0: total=1.47TiB, used=1.42TiB
System, RAID1: total=32.00MiB, used=144.00KiB
Metadata, RAID1: total=2.00GiB, used=1.52GiB
GlobalReserve, single: total=512.00MiB, used=0.00B
In my case the conversion took almost 14 hours. During this time there is of course a lot of disk activity, but it is an online conversion; the filesystem remains available.
The RAID set is still labelled SAMS2000. That is no longer accurate because there is also a Western Digital disk in the RAID set. Changing the label is done as follows:
# btrfs filesystem label /mnt/SAMS2000 RAID0
# umount /mnt/SAMS2000
# mv /mnt/SAMS2000 /mnt/RAID0
# vi /etc/fstab # update to reflect the new label and mount point
# mount /mnt/RAID0
Only after a reboot the new label will actually show:
# lsblk -o name,mountpoint,label,size
NAME MOUNTPOINT LABEL SIZE
sda 223.6G
├─sda1 64M
├─sda2 /boot SSDBOOT 512M
├─sda3 [SWAP] ssd-swap 16G
└─sda4 /mnt/SAMSSSD500 SAMSSSD500 207G
sdb 1.8T
└─sdb1 /mnt/RAID0 RAID0 1.8T
sdc RAID0 1.8T