mdadm RAID Tutorial
Here is how you make a software RAID (switch to root)
I am currently writing a python script which will automate all these steps by taking in a few parameters from the user. This is work in progress and will be available on my github repository. In the meantime you can use this tutorial as a reference.
- List all the attached disks:
lshw -class disk
- Create a full disk partition on each disk:
fdisk /dev/sd*
- Get mdadm if not already installed
apt-get install madam
- Build the Array using mdadm ( -C Create -v Verbose -l RAID Level -n Number of disks) In the example below we are deploying a level 5 RAID using three disks at /dev/md0
mdadm -C /dev/md0 -v -l 5 -n 3 /dev/sdc1 /dev/sdb1 /dev/sdd1
- Make the file system
mke2fs -t ext4 /dev/md0
mkfs.xfs -d su=64k,sw=4 /dev/device
- Add the array in the madadm.conf file
mdadm --detail --scan >> /etc/madadm/mdadm.conf
A line like this will be appended ( ARRAY /dev/md/synapse1:0 metadata=1.2 name=synapse1:0 UUID=04d1879f:4dfc2e39:b25601e0:52b1cf6 )
- Create the mount point
mkdir /data
- Add the mount point in the fstab file
vim /etc/fstab
Add this line ( /dev/md0 /data ext4 noatime,rw 0 0 )
- Restart the system and check if the RAID auto-mounts at /data
shutdown -r now
OR
reboot