Disc Mirroring with FreeBSD

The most likely components to fail in our Home Gateway server will first be fans, followed by the hard drive and then the power supply. Fans can be replaced as can power supplies. When hard drives fail, any data on them is lost. Although hard drives have become much more reliable, data protection and recovery techniques are still used in IT (information technology) S.O.P (standard operating procedures). The simplest data protection scheme which we can configure is the use of two identical hard drives with disc mirroring or what is technically referred to as RAID 1 (raid one). RAID stands for Redundant Array of Independent Disks. If you are going to build a Home Gateway using SSD drives, then employing RAID may not be required. But for mechanically spinning discs, RAID is highly recommended to keep a server working in the event of a single hard disk failure.

During the installation of FreeBSD, RAID configuration is done during the Partitioning step. This guide will continue that step and setup two drives for disk mirroring.


STEP 1 - Partitioning Method
        +------------------------Partitioning---------------------------+
	| How would you like to partition your disk?                    |
	| +-----------------------------------------------------------+ |
	| |   Auto (ZFS)  Guided Root-on-ZFS                          | |	
	| |   Auto (UFS)  Guided Disk Setup                           | |
	| |   Manual      Manual Disk Setup (experts)                 | |
	| |   Shell       Open a shell and partition by hand          | |
	| +-----------------------------------------------------------+ |
	|                                                               |
	|                                                               |
	+---------------------------------------------------------------+
	|                 <  OK  >          <Cancel>                    |
	+---------------------------------------------------------------+

Press [Enter] on Auto (ZFS) to use the Auto (ZFS) partitioning tool.
ZFS (Zettabyte File System) is required for software mirroring or RAID disks)


STEP 2 - ZFS Configuration
        +----------------ZFS Configuration-------------------+
	| Configure Options:                                 |
	| +------------------------------------------------+ |
	| | >>> Install          Proceed with Installation | |
	| | T Pool Type/Disks:   stripe: 0 disks           | |
	| | - Rescan Devices     *                         | |
	| | - Disk Info          *                         | |
	| | N Pool Name          zroot                     | |
	| | 4 Force 4K Sectors?  YES                       | |
	| | E Encrypt Disks?     NO                        | |
	| | P Partition Scheme   GPT (BIOS)                | |
	| | S Swap Size          2g                        | |
	| | M Mirror Swap?       NO                        | |
	| | W Encrypt Swap?      NO                        | |
	| +------------------------------------------------+ |
	|                                                    |
	+----------------------------------------------------+
	|         < Select >       < Cancel >                |
	+----------------------------------------------------+
[Arrow] down to select Pool Type/Disks and press [Enter]

STEP 3 - ZFS Configuration (cont.)
        +----------------ZFS Configuration-------------------+
	| Select Virtual Device type:                        |
	| +------------------------------------------------+ |
	| | stripe  Stripe - No Redundancy                 | |
	| | mirror  Mirror - n-Way Mirroring               | |
	| | raid10  RAID 1+0 - n x 2-Way Mirrors           | |
	| | raidz1  RAID-Z1 - Single Redundant RAID        | |
	| | raidz2  RAID-Z2 - Double Redundant RAID        | |
	| | raidz1  RAID-Z3 - Triple Redundant RAID        | |
	| +------------------------------------------------+ |
	|                                                    |
	+----------------------------------------------------+
	|           <  OK  >       < Cancel >                |
	+----------------------------------------------------+

[Arrow] down to select mirror Mirror - n-Way Mirroring and press [Enter]

A list of all drives will be displayed. Use the [Arrow] down key and the [Space]
key to select the drives for the RAID array. In this example, two hard drives
have been selected for the mirror. Warning, da0 is our USB installation drive, don't select it!
        +----------------ZFS Configuration-------------------+
	|                                                    |
	| +------------------------------------------------+ |
	| | [*] ada0  HGST HTS541010B7E610 01.01A01        | |
	| | [*] ada1  HGST HTS541010B7E610 01.01A01        | |
	| | [ ] da0   Philips USB Flash Drive              | |
	| +------------------------------------------------+ |
	|                                                    |
	+----------------------------------------------------+
	|           <  OK  >       < Back >                  |
	+----------------------------------------------------+
[Tab] to OK when ready and press [Enter]
        +----------------ZFS Configuration-------------------+
	| Configure Options:                                 |
	| +------------------------------------------------+ |
	| | >>>Install          Proceed with Installation | |
	| | T Pool Type/Disks:   mirror: 2 disks           | |
	| | - Rescan Devices     *                         | |
	| | - Disk Info          *                         | |
	| | N Pool Name          zroot                     | |
	| | 4 Force 4K Sectors?  YES                       | |
	| | E Encrypt Disks?     NO                        | |
	| | P Partition Scheme   GPT (BIOS)                | |
	| | S Swap Size          2g                        | |
	| | M Mirror Swap?       NO                        | |
	| | W Encrypt Swap?      NO                        | |
	| +------------------------------------------------+ |
	|                                                    |
	+----------------------------------------------------+
	|          < Install >       < Cancel >              |
	+----------------------------------------------------+
If the Pool Type/Disks is correct, press [Enter] on Install

Just press [Enter] to use the entire disk for FreeBSD.


STEP 4 - Final Confirmation
        +------------Confirmation------------------------+
	| Last Chance! Are you sure you want to destroy  |
	| the current contents of the following disks:   |
	|                                                |
	|     ada0  ada1                                 |
	|                                                |
	+------------------------------------------------+
	|              < Yes >   < No  >                 |
	+------------------------------------------------+

Note: If this is NOT what you want to do, use [Tab] to select 'No'.
This is the final confirmation. Up until now, nothing has been written to the hard disk. Proceeding will erase all existing data.

Tab to Yes and press [Enter] to continue ...

The installation extraction will proceed. It is very quick.
For more information, see the FreeBSD Handbook.

Continue with STEP 11 in FreeBSD Installation