April 4, 2006

Software RAID-1 with FreeBSD

Learn how to set up software RAID-1 on FreeBSD using gmirror—even for the root partition. Boost redundancy and protect your system with step-by-step guidance.

Prior to FreeBSD 6 if you wanted to mirror your hard drives you could use Vinum to get the job done. However it was not possible to actually mirror the root partition because of the way the boot loader worked. Now with the introduction of gmirror it’s possible to easily mirror your system hard drive without having to worry about your root partition.

# sysctl kern.geom.debugflags=16
kern.geom.debugflags: 0 -> 16

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

Metadata value stored on /dev/ad0

echo geom_mirror_load=“YES” > /boot/loader.conf

vi /etc/fstab

Change each ad to a gm, and insert a mirror after /dev. For example, /dev/ad0s1a becomes /dev/mirror/gm0s1a. Unless you’ve made extra partitions, you’ll have ad0s1 devices ending in a, b, d, e, and f and will need to edit each of those lines.

reboot

gmirror insert gm0 /dev/ad2

GEOM_MIRROR: Device gm0: provider ad2 detected.
GEOM_MIRROR: Device gm0: rebuilding provider ad2.

gmirror list | more

gmirror status

See: ONLamp.com — Using Software RAID-1 with FreeBSD for more information.