FreeBSD: System Disk Mirroring (Raid1)
Sunday, March 8, 2009 at 9:47PM I wanted to set up a Raid 1 Mirror of the boot disk on my newly installed FreeBSD system. For some reason I thought this would be hard but in reality it was only a few commands and an edit of the fstab file at the end of the system installation.
All these commands are used as ROOT and could destroy EVERYTHING.
The Following command gives the OS access to the disk.
# sysctl kern.geom.debugflags=17
Then we create the mirror array with the following command.
# gmirror label -vb round-robin gm0 /dev/ad0
We then add a line to the loader so that the mirror kernel module is loaded at boot time.
# echo 'geom_mirror_load="YES"' >> /boot/loader.conf
We have to find each /dev/ad0 entry in the fstab and change it to the mirror device. The original entries would look something like this /dev/ad0s1b. We need to take out each 'ad0' entry and replace it with '/mirror/gm0' as shown below.
/dev/mirror/gm0s1b
We then have to reboot the system to make sure the system will boot from the array.
# reboot
Then finally we add the second disk to the raid array, this will copy the contents of the first disk to the second and keep them synched.
# gmirror insert gm0 /dev/ad2
For more information the FreeBSD Handbook page on RAID1 Mirroring.


Reader Comments