This page is intended to help you set up a software-based RAID-1 array using gmirror on FreeBSD. FreeBSD 5.3 or later is required. It is highly recommended that the mirrored drives are identical. I assume no responsibility for any damages inflicted. For support please refer to the links at the bottom.
Notes: This sytem contains three hard drives: ad0, ad4, and ad5. ad0 contains system information and nothing else. ad4 and ad5 contain anything public, and are mirrored. Be sure that before you start, ad4 and ad5 are NOT mounted. This walkthrough assumes you are obliterating any data on ad5.
Clear any existing metadata on the drives:# gmirror clear /dev/ad4
# gmirror clear /dev/ad5
# gmirror label -vb round-robin gm0 /dev/ad4
If you're lucky, you get this:Metadata value stored on /dev/da1.
Done.
Can't store metadata on /dev/ad4: Operation not permitted
Then execute this command, which will have gmirror override a security feature and will reset at reboot (NOTE: The value of this command has changed according to the handbook!):# sysctl kern.geom.debugflags=16
Now load the kernel module:# gmirror load
This command should have created /dev/mirror/gm0. Install labels to the new device:# fdisk -vI /dev/mirror/gm0
# bsdlabel -w /dev/mirror/gm0s1
# newfs -U /dev/mirror/gm0s1a
Add the device to fstab to ensure that gm0 is mounted at boot:# echo "/dev/mirror/gm0s1a / ufs rw 1 1" >> /etc/fstab
Add this line to loader.conf to ensure that the geom kernel module is loaded automatically:# echo 'geom_mirror_load="YES"' >> /mnt/boot/loader.conf
Now reboot. If you're successful/lucky, you will see something like this in dmesg (dmesg | grep GEOM) at boot:
GEOM_MIRROR: Device gm0 created (id=1347930694).
GEOM_MIRROR: Device gm0: provider ad4 detected.
GEOM_MIRROR: Device gm0: provider ad4 activated.
GEOM_MIRROR: Device gm0: provider mirror/gm0 launched.
# gmirror configure -a gm0
# gmirror insert gm0 /dev/ad5