Setting up software RAID on Linux

To create a software RAID we need multiple disks connected to our server. I have connected 3 10GB disk and formatted my disks as a GTP, 9GB Linux RAID file system. To do this, be sure to use the -t switch when formatting with fdisk and you should be able to find the correct file system ID to apply.; for me it was ID 29. More info on setting up linux file systems here: Formatting Disks on Linux – Tech Shizz

We configure partitions on each exactly the same size to mitigate the problem of a replacement disk not being the exact same size as a replaced disk in the future. If you try to setup a RAID without partitions and you have disks all the same, it will work but in the event of disk failure you must replace it with an identical disk.

To create the RAID the command is:

sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1

/dev/md0 is the name/location of the new virtual disk
level=5 is the RAID configuration, RAID 0 / 1 / 5 /6 etc.
raid-devices is the physical number of disks in the RAID followed by the disk/partitons that will make it up.

We can see the new configuration by running the following 3 commands:

/proc/mdstat

ls /dev/ | grep md

sudo mdadm -detail --scan

Once this is done, you can now move on to create a file system on this new virtual disk /dev/md0.

mkfs.ext4 /dev/md0

and you can then mount it. Mounting Linux Partitions Manually and at boot – Tech Shizz

Leave a Reply

Your email address will not be published. Required fields are marked *