Today, I am going to explain that how you can create a software RAID in Linux (RedHat families). In this case, I am creating a RAID-5 with 3 disks and each disk has only 1 Giga bytes capacity. As you probably know, for RAID-5, we need at least 3 disks with the same size. So, RAID-5 writes data blocks to N-1 disks, in this case 2, and parity blocks to N disk which is 3 in this case. This means that we have 2 Giga bytes to use and RAID-5 always uses one disk for parity. And you may say that we are wasting 1 Giga bytes or 1 disk here, however you protect the system against the failure of one disk. Therefore, if one disk fails, you can replace it easily by another disk without being worry about losing data. Of course, RAID-5 has its own advantages and disadvantages but it is not related to this topic now.
So, I added 3 new raw disks. I can confirm that by running the fdisk -l command (Figure 1).
Figure 1
The md command (Multiple Disks)is used to create a software RAID. The following command builds a RAID-5 array from my 3 disks (Figure 2) and activates it:
mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
Figure 2
/proc/mdstat contains a summary of RAID/Array status. Run the following command:
cat /proc/mdstat (Figure 3)
Figure 3
Also, take a look at the /var/log/messages file (Figure 4):
Figure 4
Now, we need to dump the current RAID setup into a configuration file. Then, the configuration file can be read at startup or shutdown to esaily manage the array. Run the following commands (Figure 5):
echo "DEVICE /dev/sdb /dev/sdc /dev/sdd" > /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf
Figure 5
The following command enables array to read the /etc/mdadm.conf file at startup:
mdadm -As /dev/md0
To stop the array manually, run the following command:
mdadm -S /dev/md0
To monitor our array and send notifications for any problems by email, add a MAILADDR line to the /etc/mdadm.conf. Then, start the service (Figure 6):
echo "MAILADDR root@localhost.localdomain" >> /etc/mdadm.conf
service mdmonitor start
To start mdmonitor at boot time, run the following command:
chkconfig mdmonitor on
Figure 6
To simulate a failed disk, run the following command and then read the email notifications (Figure 7,8):
mdadm /dev/md0 -f /dev/sdc
Figure 7
Figure 8
Also, take a look at /var/log/messages file (Figure 9):
Figure 9
To remove the disk from array and array configuration, run the following command (Figure 10):
mdadm /dev/md0 -r /dev/sdc
Now, replace the disk (if it supports Hot-swap drive hardware, otherwise turn off system) and run the following command to add the disk back to array (Figure 10):
mdadm /dev/md0 -r /dev/sdc
Now, replace the disk (if it supports Hot-swap drive hardware, otherwise turn off system) and run the following command to add the disk back to array (Figure 10):
mdadm /dev/md0 -a /dev/sdc
Take a look at the log file again (Figure 10):
Figure 10
In order to use this RAID5 array, we need to format it and then mount it. Afterward, use df -h command to verify it (Figure 11):
Figure 11
To mount the array at boot time, edit /etc/fstab and add the following line (Figure 12):
/dev/md0 /media/RAID5 ext4 defaults 0 0
/dev/md0 /media/RAID5 ext4 defaults 0 0
Figure 12
And that's all.
Hope you enjoyed.
Khosro Taraghi
Hope you enjoyed.
Khosro Taraghi
Thanks I'm new to Linux and this was a huge help.
ReplyDeleteYour welcome. Glad to hear that.
ReplyDeletewhat is the best book to refer the Linux commands and basic concepts for the fresher???? pls help me
ReplyDeleteVery nice explanation... its helps a lot. thanks for sharing
ReplyDeleteThe Red Hat Linux Online Training Certification is a week-long course, provides intensive system administration training enabling participants to develop the skills they need to effectively administer Red Hat Enterprise Linux.
ReplyDeleteWe are providing Best Red Hat Linux Online Training. for more visit this link
Red hat Linux Online Training
Nice article Thank you for sharing. We are providing Best Red hat Linux Online Training. for more Visit Red Hat Linux Online Training
ReplyDeleteThis course relates to Red Hat Enterprise Linux 7 and is for IT professionals without previous Linux administration experience. Red Hat Training
ReplyDeleteThanks for nice topic. Very useful information.
ReplyDeleteIthubOnlineTraining are good in giving the <a href=" http://www.ithubonlinetraining.com/red-hat-linux-online-training/ redhatlinux onlineTraining</a>
Really it was an awesome article...very interesting to read..You have provided an nice article..We also visit here linux training,red hat training ..Thanks for sharing..
ReplyDeleteIt was a very useful Information.... Thanks for sharing.
ReplyDeleteLinux Training in Noida
I am obliged to you for sharing this piece of information here and updating us with your resourceful guidance. Hope this might benefit many learners. Keep sharing this gainful articles and continue updating us.
ReplyDeletePhp Institute in Gurgaon
Php Course in Gurgaon
Php Training in Gurgaon
Java Institute in Gurgaon
Java Course in Gurgaon
Java Training in Gurgaon
C++ Institute in Gurgaon
C++ Course in Gurgaon
C++ Training in Gurgaon
Thank you for sharing such great information very useful to us.
ReplyDeleteLinux Training in Noida
Thanks for sharing such a great blog Keep posting..
ReplyDeleteLinux Training in Delhi
Linux Training institute in Delhi
Thanks for posting. Linux Tutorial
ReplyDeleteTo do my best in the exam I chose Pass4sure Microsoft dumps for my preparation. It gave me a comprehensive understanding about every concept of the field in a way that I was able to answer each question in the final exam. I am fully satisfied with my selection of Microsoft dumps.
ReplyDeleteOutstanding post. Thanks for this great content.
ReplyDeleteDevOps Online Training
APTRON has designed its RHCE training for IT professional and wannabes who seek to achieve practical skills of networking and security administration. Our RHCE training project is armed with the faculties who are IT professional with more 10 year experience in core area and filled with technical knowledge and real world experience with the significant spotlight on practical knowledge with the end goal of giving required skills to a Linux administrator's job assignments.
ReplyDeleteFor More Info:- Linux Training in Gurgaon
Thanks for sharing, nice post! Post really provice useful information!
ReplyDeleteCông ty vận chuyển hàng nước ngoài gửi hàng đi mỹ, gửi hàng đi nhật và gửi hàng đi đài loan và dịch vụ chuyển phát nhanh đi hàn quốc uy tín, giá rẻ
Thank you for such useful information on Linux. It was really very useful.
ReplyDeleteThanks for the great article this is very useful info thanks for the wonderful post.
ReplyDeleteBest Linux Online Training Institute
linux online training ,best online course for linux
ReplyDeleteI am really impressed. you have written really nice a blog. Thanks for sharing.
ReplyDeleteBest Linux Course in Mumbai
The article is so appealing. You should read this article before choosing the Big Data Solutions Developer you want to learn.
ReplyDeleteWow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
ReplyDeleteArtificial Intelligence Training
Java Training
AWS Training
Machine Learning Training
Data Science Training
DevOps Training
Nice post..
ReplyDeleteSAP ABAP on Hana training from india
SAP ABAP training from india
SAP BW on Hana training from india
SAP mm training from india
SAP pm training from india
SAP PP training from india
SAP Qm training from india
SAP Sd training from india
Thanks for sharing such a great blog, Keep posting..
ReplyDeleteRHCSA Training
RHCE Training
Great Post. Very informative. Keep Sharing!!
ReplyDeleteApply Now for Linux Training Classes in Noida
For more details about the course fee, duration, classes, certification, and placement call our expert at 70-70-90-50-90