Linux RAID with mdadm

There are two basic ways to handle RAID in Linux; Logical Volume Management or Multiple Device Administration. (LVM or mdadm). The pros and cons of each are here, but suffice to say if you want flexibility, pick LVM. If you want simplicity and performance, pick mdadm. A good step-by-step is here

To use mdadm,
  1. Identify the volumes 
  2. use the tool mdadm to create the RAID volume
  3. format and mount
1. Identify the volumes

     sudo fdisk -l
    (You could also create partitions if you wanted to for some reason)

2. Create the volume

sudo mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sda /dev/sdb


3. Format and mount
mkfs.exfat /dev/md0 
...
...
mkdir /mnt/md0
mount /dev/md0 /mnt/md0/

4. Save your config
sudo mdadm --detail --scan --verbose >> /etc/mdadm/mdadm.conf
sudo update-initramfs -u

You may get a permission error on the first command, necessitating you manually edit that conf file.
With recent Ubuntu, there is already a mdadm.conf file that will automap your array. It will do so however at md127 unless you update the initramfs.  If you're OK with this, you can mount via UID and all is well without saving one's config (I suspect)

5. Create a auto-mount point by adding this line to your fstab

sudo blkid
...
...
/dev/md0: UUID="554F-3F0D" TYPE="exfat"

sudo vim /etc/fstab
...
...
UUID=554F-3F0D /mnt/md0 exfat defaults 1 2

Give it a reboot and see if it sticks. For problems head over to the mdadm troubleshooting

Comments