mdadm: Creating a new array
A standard command to create a new mdadm array will look similar to the following,
mdadm --create /dev/mdX --level=Y --raid-devices=Z /dev/sdaN /dev/sdbN
Underneath each individual option is explained.
Create: You will define the name of the array here. The examples all assume no arrays exist on the server yet, if this is not the case, replace md0 with the next available subsequent number.
Level: This defines the RAID level. mdadm supports RAID 0/1/4/5/6/10.
Raid Devices: The amount of drives which will part of the created array.
Partitions: Whilst not defined by appending an option, these define which partitions to place into the array. The examples below assume all drives have been provided with a partition. If none are present yet they will have to be created using a disk partitioner (eg. fdisk/gdisk/parted)
mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1
mdadm --create /dev/md0 --level=6 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
To ensure the array is re-assembled every time the Operating System is started, the mdadm.conf file will have to be generated or modified.
mdadm --detail --scan | tee -a /etc/mdadm/mdadm.conf
Additionally, the 'initramfs' will have to be re-generated to allow the array to be available during the early boot process.
The device is now ready to have a filesystem created and be mounted.