RAID (originally redundant array of inexpensive disks; now commonly redundant array of independent disks) is a data storage virtualization technology. It combines multiple inexpensive,smalldisk drives into an array of disks in order to provide redundancy, lower latency,maximized ability to recover from hard disk crashes andthere byimproving the performance. It appears to the system as a single drive. RAID can be implemented via hardware devices as RAID controllers or via software controlled by the Linux Kernel.
The commonly used RAID levels are RAID 0(2 hard disk minimum),RAID 1(2 hard disk minimum),RAID 5(3 hard disk minimum) and RAID 10(4 hard disk minimum).
RAID 1 is also known as “disk mirroring.” With RAID 1, data is copied seamlessly and simultaneously from one drive to another, creatinga exact copy or mirror. If one disk getsfailed, the other can work without issues. It’s the simplest way to implement fault tolerance andit’s low cost. But it cost slight drag on performance. This is useful when read performance or reliability is more important than the resulting data storage capacity.
The advantages of raid 1 are it offers excellent read speed and a write-speed that is comparable to that of a single drive and ifdrivefails, datadonothave to berebuild, they just need to be copied to the new replacement drive and it is very simple technology.
The main disadvantage of RAID 1 is that the effective storage capacity is only half of the total drive capacity because all data get written twice and software RAID 1 solutions do not always allow a hot swap of a failed drive.
In this article you can see the steps to configure raid level 1 inlinuxwith its commands.
First youneed to installmdadmonyour server. You can use the following commands to installmdadm.
# yum install mdadm
#apt-get install mdadm
The next step is to create a RAID array is to create the disk partitions (with the same size) that are going to be the array members as RAID partition. To createpartitionyou can use the following commands.(RAID for partitions /dev/sdb1 and /dev/sdc1)
Then press ‘n’ for creating a new partition in /dev/sdb. Then press ‘p’ for use it asprimary partition. Enter thepatitionnumber. You can use the full size by just pressing two times ‘Enter key’. Then press ‘t’ to choose thepatitiontype. Then choose ‘fd‘for Linux raid auto and press ‘Enter Key’ to apply it. Pressing ‘p’verifythatthe partition is created aslinux raidautodetect.Press ‘w’ to save the changes.
Follow the same instructions to create new partition on /dev/sdcdrivetoo with same partition size.
The next step is to create a RAID 1 sdb1,sdc1 array using commandmdadm:
# mdadm –create –verbose –level=1 –raid-devices=2 /dev/md0 /dev/sdb1 /dev/sdc1
–create–> create a new RAID device.
–verbose–>print information about its operations.
/dev/md0 is the new RAID device that we want to create.
–level–> defines the RAID level; in our case, RAID 1 (Mirror).
–raid-devices –> It specifies how many disks (devices) are going to be used in the creation of the new RAID device.(here 2 — /dev/sda1 /dev/sdb1)
You can verifyraid statususing the following command.
#mdadm -E /dev/sd[b-c]1
# mdadm –detail /dev/md0
The next step is toformatingthe partition and creating file system and mounting it.
#mkfs.ext4 /dev/md0 –> to format the partition
tomount/dev/md0 to /raid1 perform the below steps.
# mkdir /raid1
# mount /dev/md0 /raid1
# df -H –> you can verify it is mounted
To auto-mount RAID1 on system reboot, need to make an entry in ‘/etc/fstab‘ file.
Add the following line to the file.
/dev/md0 /raid1 ext4 defaults 0 0
Then run ‘mount -a‘ to check whether there are any errorsinfstabentry.
Now update /etc/mdadm/mdadm.confor/etc/mdadm.conffileas follows:
ARRAY /dev/md0 devices=/dev/sdb1,/dev/sdc1 level=1num-devices=2 auto=yes
# mdadm –detail –scan >> /etc/mdadm.conf