Firstly you need to install ‘mdadm’ utility on our system, if not installed already
$ yum install mdadm
After installing ‘mdadm’, we will prepare our disks sdc & sdd for RAID configuration with the help of ‘fdisk’
- Firstly we will prepare /dev/sdc disk for LVM, start by
- Type ‘n’ for creating a new partition,
- Next type ‘p’ for creating the primary partition (since this is a new disk, partition number will be 1 )
- Nest for First cylinder value & last cylinder value, press enter to use default values i.e. full HDD space
- Type ‘t’ for accessing the partition followed by ‘1’ (partition number)
- Now, this is the part where we will enter the partition id for creating RAID i.e. ‘fd’. Type ‘fd’ now & press ‘w’ to write changes.
- The same process is to be followed for /dev/sdc as well. When both disks have been partitioned, we can examine them usingThe same process is to be followed for /dev/sdd as well. When both disks have been partitioned, we can examine them using
Now that we partitioned both HDDs, we will create RAID array (aka md device) named ‘/dev/md1’ using the following command
mdadm –create /dev/md1 –level=mirror –raid-devices=2 /dev/sd[c-d]1
We will now verify our RAID array by running the following command
$ cat /proc/mdstat/dev/sd[c-d]1
For complete details regarding the RAID 1 array, we use the following command$ mdadm –detail /dev/md1
RAID array is ready but still can’t be used as we have not assigned it a filesystem & have not mounted it on our system. So we will assign a filesystem first using ‘mkfs’ command$ mkfs.ext4 /dev/md1
& next we will mount it on /data,
$ mkdir /data
$ mount /dev/md1 /dataBut this is only a temporary mount & will not survive a reboot. So we will make an entry into /etc/fstab
$ vi /etc/fstab
/dev/md1 /data ext4 defaults 0 0
Save & exit the file. Our RAID array is now permanently mounted to /data.
Lastly, we will create backup of the RAID configuration in order to use it further
$ mdadm -E -s -v >> /etc/mdadm.conf
$ mdadm –detail –scan –verbose >> /etc/mdadm.conf
$ cat /etc/mdadm.confNote : I have tested this on AWS using CentOS it worked well for me
Thank you,
Nuwan Vithanage