This is an article on ” How we can Configure RAID 1 on FreeBSD”
I have done the OS installation ( with RAID 1 ) on FreeBSD 11.04 consisting of 2 disks ( 250 GB SSD )

How to Configure RAID 1 on FreeBSD?

First of all we need to familiarize how the disks are named in the OS.
Normally in FreeBSD, each disk will be named as “ada0” and “ada1” respectively.
Because, on other Linux OS’s like CentOS, Ubuntu, Debian the disk will be named as “sda” and “sdb”

Step 1 : 

Mount the ISO, then reboot the server and Start the FreeBSD install as we normally do.

Choose “Shell” option once you are prompted to the window as below

Step 2 : Setting up the partitions on the disks

Make sure that both the disks are clean and there are no other partitions on the disk.
If you have any doubt, we can destroy the existing partitions.

Use this commands to destroy the partition

  • gpart destroy ada0
  • gpart destroy ada1

Once you are on the shell prompt, we now need to manually partition both the disks.
Here we are using the below mentioned partition layout:

/boot : 128k
swap : 4G
/ : rest of the space

##Setup 1st disk
gpart create -s gpt ada0
gpart add -s 128k -t freebsd-boot -l boot0 ada0
gpart add -a 1m -s 4G -t freebsd-swap -l swap0 ada0
gpart add -a 1m -t freebsd-ufs -l root0 ada0

##Install boot code to first disk
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0

##Setup 2nd disk
gpart create -s gpt ada1
gpart add -s 128k -t freebsd-boot -l boot1 ada1
gpart add -a 1m -s 4G -t freebsd-swap -l swap1 ada1
gpart add -a 1m -t freebsd-ufs -l root1 ada1

##Install boot code to 2nd disk
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1

Step 3: Setup The Gmirror

true > /dev/ada0
true > /dev/ada1

Once done, we can check whether the partitions configured are assigned correctly by using this command

  • ls -l /dev/gpt/

You will be displayed a result as like

Now we need to build mirrors for each partition we configured.
For this we use “gmirrors”

gmirror label -h boot /dev/gpt/boot0 /dev/gpt/boot1
gmirror label -h swap /dev/gpt/swap0 /dev/gpt/swap1
gmirror label -h root /dev/gpt/root0 /dev/gpt/root1

Now load the geo_mirror KLD
#kldload geom_mirror

Then we can check the status of the gmirror. If it is okay, the Status will be “Complete” and all the Components will be “Active”.

Step 4 : Mount the Root(/) file system

Here we are using SSD. For this we need to use the option “-t” to the newfs.
This will help to enable the TRIM Support.

#newfs -t -U -L root /dev/mirror/root

Now mount the new file system to “/mnt”
#mount /dev/mirror/root /mnt

Step 5: Exit out from the shell prompt by using “exit” to continue with the Installation process.

Step 6: You will be now prompted to a choose system components to install

Step 7: Next will be partitioning. Choose again Shell from the next window

Once you are again prompted to shell, we now need to create the partitions to fstab file to complete the process.

#vi /tmp/bsdinstall_etc/fstab
Edit the file as updated below :

Device                     Mountpoint     FStype  Options  Dump  Pass#
/dev/mirror/swap none                 swap     sw          0             0
/dev/mirror/root  /                         ufs         rw          1              1

Step 8: Exit

Once the installation is completed, you will be prompted to a window like

choose “Yes”. You will be again booted to Shell prompt.
If we are not doing these steps, there is a chance  for getting “mount root” error.

Proceed with the below steps:

Edit “/boot/loader.conf” with the entry   geom_mirror_load=”YES

Reboot the server, once the Installation completed.

You will be now booted into the OS.

ServerAdminz provides Outsourced 24/7 Technical Support, Remote Server Administration, Server Security, Linux Server Management, Windows Server Management and Helpdesk Management to Datacenters, Hosting companies and ISPs around the world. We specialize in Extended Server Security, Server Hardening, Support for Linux/UNIX/Windows servers, products and services.We provide Unix/Linux/Windows Server Management to Data centers, large companies and ISPs around the world.

ServerAdminz is a server support company specialized in Outsourced 24/7 Web Hosting Support, Remote Infrastructure Management, NOC, Cloud and Enterprise Security Services. With over 10+ of years of experience in working with major Data Centers and ISPs with 130+ experienced technicians, we continue to manage more than 49,000 servers from 85+ countries and has bagged 5 international awards.