Posted by: jasonk2600 | December 4, 2009

Quickie HowTo – Creating a RAID 1 Array on FreeBSD

Notes & Hardware Setup

The following how to describes how to setup a RAID 1 (or mirrored) array with FreeBSD.  It is assumed that the system you are working with has two identical drives that will be entirely dedicated to the RAID 1 array.  The examples below will make use of two identical drives called /dev/afd0 and /dev/afd1, replace the names of the two drives to reflect your system’s settings throughout.

 

Initialize The Drives

Begin by clearing off all data from the two drives.  This can be done with the dd command:

# dd if=/dev/zero of=/dev/afd0 bs=1k count=2
# dd if=/dev/zero of=/dev/afd1 bs=1k count=2

Initialize the two drives with the bsdlabel utility:

# bsdlabel -w /dev/afd0 auto
# bsdlabel -w /dev/afd1 auto

Using gmirror, create the RAID 1 array with one of the disks you prepared above.

# gmirror label -vb round-robin gm0 /dev/afd0
# gmirror load

 

Next, setup the gmirror kernel module to automatically load by adding it to the /boot/loader.conf file.

# echo 'geom_mirror_load="YES"' >> /boot/loader.conf

 

Add the newly created RAID 1 device to the /etc/fstab file to have it automatically mounted at system boot. NOTE: In the example below the RAID 1 device is automatically mounted to the /raid directory, you may change this to a mounting point of your choice.

# vi /etc/fstab
   /dev/mirror/gm0   /raid   ufs   rw   2   2

 

Finally, reboot the system. Once the system has rebooted add the second disk, that was previously prepared, to the RAID 1 array. You can check for errors and the status of the mirrored array by using the gmirror status command.

# shutdown -r now
# gmirror insert gm0 /dev/afd1
# gmirror status

Reference(s):

 

  [EoF]
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: