Edit: 12/06: Fixed md127 mount bug
Edit: 13/06: Discovered that the RAID device was 2TB instead of 3TB. Added fix.
Update: 18/06: Can watch syncing using “watch -n 2 cat /proc/mdstat”

After getting frustrated at the low transfer speeds from my FreeNAS server I decided to install Mint onto it instead and use mdadm to mirror my drives. The slow speeds weren’t really to do with FreeNAS but rather the slow NICs connecting to it. I purchased a new motherboard with gigabit ethernet, but the other computers had 10Mbit connections:

10Mbit/s = 10^7bit/s = 10^7/(8*1000*1000)MB/s = 1.25MB/s
10Mbit/s = 10^7bit/s = 10^7/(8*1024*1024)mebibytes/s ~= 1.19 MiB/s

By installing an OS I can utilise the USB3 ports to copy my files onto the mirrored drives at much faster speeds…

I’ll also feel more comfortable with a more universal filesystem.

Bootable Flash Drive:
Download the .iso from the Mint website.

Find the mount point of the flash drive: sudo fdisk -l
Then write the image to the drive using: sudo dd if=~/Desktop/linuxmint.iso of=/dev/sdx oflag=direct bs=1048576
Install Linux Mint following these partitioning guidelines.

Remote Connection:
Once installed you might like to work on the computer from another room. If so, first install an SSH server:
sudo apt-get install openssh-server

Format the Drives: 
I’ll reformat the two drives that we’ll be mirroring. To do this you can use fdisk /dev/sdx (or simply use Gparted):

sudo fdisk /dev/sdb
then use ‘d’ to delete an existing partition
then use ‘w’ to write to the disk
go back into fdisk and use ‘n’ to create a new partition
then use ‘p’ to create a primary partition
use ‘1’ to create one partition and use the defaults () for the first and last sectors.
use ‘t’ to change the partition type
enter ‘fd’ to set the type as “Linux RAID auto”
finally use ‘w’ to write everything to the disk.

If the disks you are using are >=2TB the partition table needs to be in GUID format (GPT) rather than the old MS-DOS (MBR) format. Otherwise you won’t have more than 2TB usable space – even if the hard-drive is larger.
This means that you can not use fdisk, instead we need to use parted:

Stop the RAID device (see below).
Identify the disks using sudo fdisk -l.
Run parted /dev/sdx.
At the (parted) prompt, create the partition table by typing mklabel gpt.
Check the free space on the drive by typing print free. In my case, this shows 3001GB.
Create the partition by typing mkpart primary 1M 3001GB. This starts the partition a 1M offset giving a 4096 byte alignment. This may or may not be necessary, but won’t hurt if its not.
Check your partition is set up by typing p.
Then type q to quit.
Repeat with the other drive(s).

Once you have finished you should have the partitions /dev/sdb1 and /dev/sdc1 on the /dev/sdb and /dev/sdc disks respectively.

Create the RAID:
We first need to remove dmraid so it doesn’t take control of the devices:

sudo apt-get remove dmraid libdmraid1.0.0.rc15

sudo update-initramfs -u
sudo reboot

We can then create our virtual RAID device:
sudo apt-get install mdadm
mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1 

This will create the /dev/md0 virtual device from the two real block devices /dev/sdb1 and /dev/sdc1, configuring it in mirror mode. (the drives will no longer be visible in My Computer).

Check out the /proc/mdstat file. It should tell you that the /dev/md0 device has been started, that the mirror is being reconstructed, and an ETA of the completion of the reconstruction:
cat /proc/mdstat

You can also see some detailed information on your RAID device using:
sudo mdadm --detail /dev/md0

Reconstruction is done using idle I/O bandwidth. So, your system should still be responsive, although your disk LEDs should be glowing nicely.
The reconstruction process is transparent, so you can actually use the device even though the mirror is currently under reconstruction.

Saving Your RAID Configuration:
After you’ve created your array, it’s important to save the configuration in the proper mdadm configuration file. In Ubuntu, this is file /etc/mdadm/mdadm.conf.

If you have lost this file you can create a template using:

sudo update-initramfs -u

You then need to append the details of  ARRAY. This can be done using:
sudo su
mdadm --detail --scan --verbose >> /etc/mdadm/mdadm.conf

To prevent the md127 naming error you’ll want to remove some unnecessary detail from this file. All you need is a device name and a UUID but just removing “name = xxx” fixes any problems:
sudo nano /etc/mdadm/mdadm.conf

You’ll then want to update initramfs so it contains your mdadm.conf settings during boot:
sudo update-initramfs -u

If you get errors, first stop your RAID device:
sudo mdadm --stop /dev/md127

Create and Mount Filesystem:
Now, you can create a filesystem, just like you would on any other device, mount it, include it in your /etc/fstab.

First I’ll format the RAID with the ext4 filesystem:
sudo mkfs.ext4 /dev/md0

Next well create a folder and mount the RAID:
sudo mkdir /raid1
sudo mount /dev/md0

We also need to give ourselves permission to write to the folder:
sudo chmod 777 /raid1

The last thing we need to do is add an entry in /etc/fstab so that the RAID is automatically mounted when the computer starts:
sudo echo "/dev/md0 /raid1/ ext4 defaults 1 2" >> /etc/fstab

/dev/md0 /mnt/md0 auto rw,user,exec 0 0

See here for details in editing the fstab file.

You might need to change the permissions once you restart:

chmod 777 /raid1/

If you are like me you will run into problems and want to start over. When I restarted my RAID device seemed screwed up …

The first thing to do is a sudo fdisk -l or cat /proc/mdstat to see if you RAID device exists. Mine showed up as /dev/md127 – I have no idea how it changed to 127…
You can get details of the RAID device using the following:
mdadm --detail /dev/md127

Unmount the device if you have it mounted:
sudo umount /dev/127

You might need to kill a process that is keeping it busy:
fuser -m /
ps aux | grep
Note: for me this was terminal

Anyhows, we can now stop md127:
sudo mdadm --stop /dev/md127

It will no longer be visible if you perform a sudo fdisk -l or cat /proc/mdstat. To start it again you need to resemble the array: sudo mdadm -A /dev/md127 /dev/sdb1 /dev/sdc1

Once the array has been stopped, we need can remove the zero-blocks from the component devices:
sudo mdadm --zero-superblock /dev/sdb1
sudo mdadm --zero-superblock /dev/sdc1

Lastly we need to remove the entry in the /etc/mdadm/mdadm.conf file and then restart mdadm:
sudo nano /etc/mdadm/mdadm.conf (and delete the last couple of lines)
sudo /etc/init.d/mdadm restart