FreeBSD Software RAID-1
These notes are based upon the following articles:
- Using Software RAID-1 with FreeBSD
- FreeBSD System Disk Mirroring
- RAID1 - Mirroring (The FreeBSD Handbook)
The instructions given here are only applicable to a new operating system install. Refer to the articles above for instructions for modifying an existing installation.
It should also be noted that these instructions were tested with a FreeBSD 6.1-RELEASE install, but should work with 5.3-RELEASE or newer.
Disks Used
These instructions assume that you have two disks that are either the
same size, or the second disk is larger than the first. In the
commands that follow, I am installing a RAID-1 on two identical 250GB
SATA disks, which appear in FreeBSD as /dev/ad4 and /dev/ad6.
Install the Operating System
Install the operating system as you would normally, only installing to the first disk. There is no need to do anything with the second disk. There is also no need to do anything special with your swap partition as some articles may mention.
Post-Installation
After you have finished installing FreeBSD, but before you leave the installer and reboot, switch to the fourth virtual terminal using Alt-F4, where you should see a command prompt. Enter the following commands there:
$ sysctl kern.geom.debugflags=16 $ gmirror label -v -b round-robin gm0 /dev/ad4 $ echo geom_mirror_load=\"YES\" >> /boot/loader.conf $ sed -i .orig -e 's|/dev/[a-z]*[0-9]*|/dev/mirror/gm0|' /etc/fstab
Adding Disk Two
You can now reboot your system. Read the first article mentioned above if you run into trouble. After the system reboots, you can add your second disk to the mirror:
$ gmirror insert gm0 /dev/ad6
It will take some time to sync the second disk. My 250GB SATA disk
took about an hour. You can check on the sync status using gmirror
status.
Replacing a Failed Disk
Replace the disk, say /dev/ad6, and then:
$ gmirror forget data $ gmirror insert gm0 /dev/ad6