Software RAID1 on FreeBSD
Setup: Two HDDs, /dev/ad0 and /dev/ad2
Files: /etc/fstab and /boot/loader.conf
FreeBSD ships with gmirror, which makes software RAID easy to setup and manage.
Set sysctl so gmirror can do its thing:
# sysctl kern.geom.debugflags=16
Create a mirror/duplex with the first drive:
# gmirror label -v -b round-robin gm0 /dev/ad0
Where gmirror label creates the mirror;
-v enables verbose mode;
-b round-robin chooses a balance algorithm (at the moment, round-robin is the algorithm with the best performance);
gm0 is the name of mirror/duplex (this name represents the first GEOM mirror);
/dev/ad0 represents the disk containing the data to mirror.
# echo geom_mirror_load="YES" >> /boot/loader.conf
# cp /etc/fstab /etc/fstab.old
# vi /etc/fstab
Change each ad to a gm, and insert a mirror after /dev.
For example, /dev/ad0s1a becomes /dev/mirror/gm0s1a.
# shutdown -r now
Reboot and insert the second drive into the array
# gmirror insert gm0 /dev/ad2
# gmirror list | more
# gmirror status