Software RAID (gmirror) in FreeBSD

Posted on Wed 27 August 2008 by Pavlo Khmel

Step-by-step operations in command line to setup Soft RAID.
Before setup:

sysctl kern.geom.debugflags=16

To create mirroring on disk /dev/ad0 :

gmirror label -v -b round-robin gm0 /dev/ad0

Changing configuration to boot from RAID:

echo geom_mirror_load="YES" > /boot/loader.conf

Changing /etc/fstab. Instead /dev/ad0s1a should be /dev/mirror/gm0s1a ( change "ad" to "mirror/gm"). If you have "ad4" change to "gm0".
Reboot.
Adding second disk:

gmirror insert gm0 /dev/ad2

Waiting for rebuilding new RAID:

gmirror list | more
# or:
gmirror status

If one disk is failed:

gmirror forget gm0
gmirror insert gm0 /dev/ad0

if first disk failed.
If you need rollback:

gmirror forget gm0

And change files to previous state: /boot/loader.conf and /etc/fstab.
Reboot.