Marius van Witzenburg "Learned my lesson in life, now setting my action to stay in life."

2Jul/100

How to setup a GEOM Raid mirror on FreeBSD with gmirror

To setup GEOM Raid you first have to prepare the master disk with gmirror. To do this you first have to label the disk with gmirror and load gmirror it self.

kldload geom_mirror
sysctl kern.geom.debugflags=17
gmirror label -vb round-robin gm0 /dev/ada0

Since we want our Raid mirror to remain active after a reboot we have to add gmirror to the loader.conf in /boot.

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

After that you should replace the devices in /etc/fstab with the new geom mirror device. I used sed to easy replace it, some people prefer to replace it by hand.

sed -i .orig -e 's|/dev/ada0|/dev/mirror/gm0|' /etc/fstab
shutdown -r now

Now our mirror is prepared we can add more disks to the array so we will get our actual mirror.

gmirror insert gm0 /dev/ada1
gmirror insert gm0 /dev/ada2
gmirror insert gm0 /dev/ada3
gmirror status

In case you want to disable write cache to be sure everything gets written directly you should add the following to /boot/loader.conf:

hw.ata.wc=0