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.

Prev Post: Incremental backup with rsync
Next Post: Track processes IO load
Main Page: ZulusTips index

7 Responses to “HOWTO: Software RAID1 on FreeBSD”

  1. Joe Says:

    Thank you for an easy to read explanation. It’s much easier than reading the FreeBSD man pages (which get very technical). Thanks.

    - joe

  2. Lonnie Olson Says:

    See also
    http://www.onlamp.com/pub/a/bsd/2005/11/10/FreeBSD_Basics.html

  3. Skif Says:

    See handbook for more information.

  4. Zulus Says:

    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.

  5. Zoltan Says:

    Also See:

    http://www.superglobalmeganet.com/?mo=TT&q=How_to_Mirror_2_Drives_using_FreeBSD_6.x

  6. wkaha Says:

    see also http://people.freebsd.org/~rse/mirror/

  7. Charles Wang Says:

    Thank you! It saves me much time on reading the handbook.

Leave a Reply

You must be logged in to post a comment.