glabel label -v local1 /dev/da1
glabel label -v local2 /dev/da2
gmirror label -vh -b round-robin gm0 /dev/label/local1 /dev/label/local2
echo 'glabel_load="YES"' >> /boot/loader.conf
echo 'geom_mirror_load="YES"' >> /boot/loader.conf
Load the mirror:
gmirror load
Let's verify that the mirror was created:
ls /dev/mirror/gm*
You should see an output like /dev/mirror/gm0
Now we need to put a filesystem on our new mirror:
newfs /dev/mirror/gm0
We’re going to mount this mirror on /backups, so we need to create the directory:
mkdir /backups
Finally, lets add the mirror to the /etc/fstab:
/dev/mirror/gm0 /backups ufs rw 2 2
We should be able to mount the new mirror:
mount /backups
To Rebuild The Mirror
Lets say the da1 drive of mirror gm0 is acting funky:
- replace the drive. (if it’s hot swappable, be sure to use camcontrol to scan the SCSI bus.)
- break the mirror
gmirror forget gm0(this breaks the mirror) - Add the new drive to the mirror
gmirror insert gm0 da1 - Check to see if the mirror is automatically rebuilding by using
gmirror status -sIf it isn’t rebuilding:gmirror rebuild gm0 da1
Just wait for it to rebuild, and you’re done!