Using GMirror on FreeBSD 7.1
Creating a RAID 1 array in FreeBSD is simply just easy. After following a few references myself, I have decided to document the steps on my site to help in the future and well to help anybody else interested in a simple solution.
[Allow the mounted disk (ad0) to be modified by gmirror]
This step allows the gmirror utility to modify your drive while it is mounted and is a one time operation during gmirror setup, and will not be restored on reboot.
# sysctl kern.geom.debugflags=16
[Create the mirror on ad0]
This command modifies the drive label meta-data on your hard disk so that it is recognized as a gmirror RAID disk. In the example I set gm0 but you can give it any label you like as long as you're consistent. You will need this later to modify your /etc/fstab.
# gmirror label -v -b round-robin gm0 /dev/ad0
[Modify /boot/loader.conf to load gmirror on startup]
Using your favourite editor, ee or vi which ship by default on FreeBSD, modify your loader.conf file so that the gmirror module automatically loads at startup.
# ee /boot/loader.conf
Add the following
geom_mirror_load="YES"
[Modify /etc/fstab]
In this step you are modifying the /etc/fstab file so that it will mount the gmirror device gm0 rather than ad0 that the system was previously using. Here is what your old fstab might look like:
# old /etc/fstab device file
/dev/ad0s1b none
/dev/ad0s1a /
/dev/ad0s1e /tmp
/dev/ad0s1f /usr
/dev/ad0s1d /var
Again, use your favourite editor, ee or vi to modify the /etc/fstab file. Here is what your modified /etc/fstab file should look like in reference to example above.
# newly modified /etc/fstab device file
/dev/mirror/gm0s1b none
/dev/mirror/gm0s1a /
/dev/mirror/gm0s1e /tmp
/dev/mirror/gm0s1f /usr
/dev/mirror/gm0s1d /var
After this has been completed and make sure no spelling mistakes in your "/etc/fstab" Reboot you machine.
# shutdown -r now
Now when the system come back up you will need to add the second drive to the Raid 1 array using gmirror, In my case it is references as (ad1)
[Use the gmirror insert command to add the 2nd drive for mirroring]
# gmirror insert gm0 /dev/ad1
GEOM_MIRROR: Device gm0: provider ad1 detected
GEOM_MIRROR: Device gm0: rebuilding provider ad1
[Check the mirroring status]
# gmirror status
Name Status Components
mirror/gm0 DEGRADED ad0
ad1 (24%)
the system has detected the array to be "DEGRADED" and is automatically rebuilding the drive array.
[Helpful Commands to keep as reference for recovery reasons only or drive replacement]
gmirror forget gm0 /dev/ad1
gmirror insert gm0 /dev/ad1