How to Setup RAID

Post by on May 11, 2014

First, you need to choose between hardware RAID and software RAID. There is plenty of debate as to which is better. My conclusion is that software RAID is better unless you have serious concerns about performance. If you're just hacking something together or want a simple solution software RAID will fit your needs. Now, I say that opinion from the perspective of using Linux. If you're on Windows or other OS it may be a different story. Here are a few bullet points as to why I would choose software RAID:

  • At least from what all the reviews say, there isn't a noticeable performance difference between hardware and software (these are normal reviews, not enterprise solution reviews).
  • You don't have to buy any new hardware with software RAID.
  • You aren't locked into a any manufacturer with software RAID, there are many free open-source non-proprietary solutions such as mdadm and brtfs.
  • Software RAID is extremely easy to setup and maintain (from what I can tell).

But, do your own research. As always, understand the problem you are trying to solve and understand the tools available for solving it before deciding which. See "Further Reading" for some links I used in my own research.

How to Setup RAID with mdadm

I found a great simple comment by dtfinch on Ubuntu Forums that explains how to setup RAID with mdadm. Here is the summary:

1. Find Your /dev's

First, you need to figure out what your devices are:

$ lsblk
sda      8:0    0    70G  0 disk 
├─sda1   8:1    0    50G  0 part 
├─sda2   8:2    0    20G  0 part
sdb      8:0    0   500G  0 disk
sdc      8:0    0   500G  0 disk

Now, isn't that just fancy? So, we see our 70 G drive that I have the OS installed on and the two extra hard drives. Notice there aren't any partition tables? That comes next.

2. Create Partitions on Your Drives

Next, you have to create partitions on your drives. You don't have to format them to a particular fs just create the partition tables. You can do this very easily with fdisk or gparted live. With fdisk just do:

$ fdisk /dev/sdb
Command (m for help): n
# then, hit enter a bunch of times
Command (m for help): w

Then, do the same for sdc.

3. Create the RAID Drive

Next, you will create the RAID drive. If mdadm isn't installed just run sudo apt-get install mdadm.

$ mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1

Now, /dev/md0 will be our new RAID device.

4. Edit the mdadm.conf

Append array details to mdadm.conf:

$ mdadm -Es | grep md0 >> /etc/mdadm/mdadm.conf

5. Update initramfs

$ update-initramfs -u

6. Create the Filesystem

$ mkfs.ext4 /dev/md0

7. Add the Drive to fstab

Next, add the drive to fstab so it will auto-mount:

$ /dev/md0 /mnt/bup ext4 defaults,nobootwait,noatime 0 2

Change "/mnt/bup" to whatever path you want. Your RAID drive will be accessible at that location then. You can change the options like "nobootwait" and "noatime" to whatever you find in "man mount". Note: you don't need nodiratime if using noatime (link).

8. Mount the Drive

Finally, you can either reboot the PC or mount the drive right away:

$ mount -a


In conclusion, use the right tool for the job and know that software RAID is super easy to setup. mdadm has a lot of other options to explore and there is also brtfs to look at too.

Further Reading

Older Posts »