Sunday 9 August 2020

How To Create RAID 5 Software Array in Linux

 In this post let's create a RAID 5 array in a linux server

As you can see below, the server has 5 devices attached to it , one is root device we will use the other devices to create the RAID 5 array. 

 

 

We are creating raid5 array with 3 devices and one spare devices 

 

Confirm if the raid5 array is complete

 

 You can also run lsblk command to see all the four devices are raid members,

 

 We need to create the mdadm.conf file to store the raid configuration of the RAID5 array we created, as linux don't automatically remember this configuration, this configuration file will help in rebuilding or reactivating the raid array.

 

We will create ext4 filesystem on the raid device /dev/md0 and mount it to start using for File I/O operations

 

 

In above image you can see that the raid device /dev/md0 is of size 20G , but we used 3 devices of 10 GB each to create the array , the reason why it's 20G instead of 30G is that one disk space is used for storing the parity information. 

Now that the raid setup is complete, let's fail a device and see how the spare device replaces it to understand the redundancy it provides, in the below image we are failing the device /dev/xvdc and once the device fails the spare device /dev/xvde replaces it and starts rebuilding. 

 

Please note Raid 5 is not recommended for Amazon EBS, refer https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/raid-config.html