HOWTO: Software RAID1 on FreeBSD
Since 5.3-Release, FreeBSD has gmirror utility, which allows you create software RAID1. So if you have some low-end server and you need some redundancy - gmirror is right choice.
RAID1 creation process is _very simple_ and completely described in gmirror(8) man page, but i will post small how-to here.
First of all you need check that you have two identical drives. Second drive may be bigger, but total array size = smaller drive size. You can create RAID1 using this command:
gmirror label -v -b round-robin gm0 /dev/ad4
Where gm0 is array name, /dev/ad4 is first drive. If you get this message “Can’t store metadata on /dev/da4: Operation not permitted” you need to set sysctl value kern.geom.debugflags to 16:
sysctl kern.geom.debugflags=16
Next you need make backup copy of your current /etc/fstab. After this open fstab in your favorite text editor and change all /dev/ad4 to /dev/mirror/gm0. And as a last step before reboot you need add automatic geom_mirror.ko module loading:
echo geom_mirror_load=YES >> /boot/loader.conf
Double-check all, and reboot server. After reboot you need attach second drive to array:
gmirror insert gm0 /dev/ad6
If you check messages log now, you will find something like this:
GEOM_MIRROR: Device gm0: provider ad6 detected.
GEOM_MIRROR: Device gm0: rebuilding provider ad6.
Rebuild can take up to 6 hours, depends on HDD size, or system load. You can check rebuild process using this command:
gmirror status
Or more detailed output:
gmirror list
Also a good idea to add RAID status to monitoring.
When sync completed, you will have redundant system and ~2x faster IO (only read) performance.
December 26th, 2006 at 7:12 am
Thank you for an easy to read explanation. It’s much easier than reading the FreeBSD man pages (which get very technical). Thanks.
- joe
December 26th, 2006 at 7:16 am
See also
http://www.onlamp.com/pub/a/bsd/2005/11/10/FreeBSD_Basics.html
December 26th, 2006 at 11:13 am
See handbook for more information.
December 26th, 2006 at 11:33 am
Skif, i know about handbook, but there is a lot of useless information. I just want write small how-to about gmirror RAID1. Link from Lonnie Olson, IMHO, is much better describes RAID1 creation than handbook.
December 26th, 2006 at 6:54 pm
Also See:
http://www.superglobalmeganet.com/?mo=TT&q=How_to_Mirror_2_Drives_using_FreeBSD_6.x
December 27th, 2006 at 11:04 pm
see also http://people.freebsd.org/~rse/mirror/
May 28th, 2007 at 2:15 pm
Thank you! It saves me much time on reading the handbook.