First, avoid any problem by getting two identical hard drive (or at least, same size and speed at least if not from same manufacturer).
This tutorial assume both your hard disk are “da0” and “da1“. If you don’t know you’re devices name, simply use “dmesg” or “df -h” command to find out.
First, let’s temporary disable the security feature that indicate the primary disk is mounted and in use :
sysctl kern.geom.debugflags: 0 -> 16
Let’s start making the mirror device :
gmirror label -v -b round-robin gm0 /dev/da0
Tell the OS to load geom at startup :
echo geom_mirror_load="YES" > /boot/loader.conf
We need to edit fstab to tell FreeBSD to use the mirror device, so I suggest making a backup of the original file before edit :
cp /etc/fstab /etc/fstab.bak vi /etc/fstab
Here a sample of /etc/fstab before modification :
# Device Mountpoint FStype Options Dump Pass# /dev/da0s1b none swap sw 0 0 /dev/da0s1a / ufs rw 1 1 /dev/da0s1f /home ufs rw 2 2 /dev/da0s1e /tmp ufs rw 2 2 /dev/da0s1d /var/log ufs rw 2 2 /dev/acd0 /cdrom cd9660 ro,noauto 0 0
We need to change the devices to “/dev/mirror/gm*“. There is how the stab file look like after being modified :
# Device Mountpoint FStype Options Dump Pass# /dev/mirror/gm0s1b none swap sw 0 0 /dev/mirror/gm0s1a / ufs rw 1 1 /dev/mirror/gm0s1f /home ufs rw 2 2 /dev/mirror/gm0s1e /tmp ufs rw 2 2 /dev/mirror/gm0s1d /var/log ufs rw 2 2 /dev/acd0 /cdrom cd9660 ro,noauto 0 0
Ok, almost done. You may reboot you’re system now. Make sure there is no error in fstab, because you’re system may not boot! If it happen, this is not a big deal, use the FreeBSD boot CD, and use the Fixit option to correct you’re mess!
Once you’re system is rebooted, synchronize the mirror using this command :
gmirror insert gm0 /dev/da1
You can follow the sync with this command :
gmirror list | more