How to Setup Software RAID for CentOS

Today I’m going to to show you guys on how to setup software RAID on CentOS. This technique is an alternative instead of getting the expensive RAID card for your server. Though I had to warn you, getting software RAID means its involving a few manual approach and the usage of command lines instead. But nevertheless, software RAID is reliable and also will save a lot of cost 😉

You can follow the whole normal installation process of CentOS that I have wrote earlier here:

How to install Linux CentOS

Please make sure before this installation, you will need 2 identical hard disk with same space connected to the server. But the truth is, you don’t need to same hard disk with the same space amount, but as long as you partitioned the space equally then it would be good as well. But for beginner, it is better to get a hard disk that got the same space quantity, less percentage that you would get yourself confused.

But for this tutorial, the only difference will be during the hard disk review and partitioning instruction.  Below are the steps on how to do the software RAID continuing from the hard disk partitioning section:

1) Upon entering the partitioning review, it should looks like this:


2) Next is to delete every partition and left with only free space for both hard disk. It should looks like this:


3) So click the New button (or the F2 button) to start creating new partition. Straight away change the File System Type into Software RAID. In the Allowable Drives, please select SDA first, somehow CentOS won’t work if we select both hard disk at the same time. Put 100 for the Size as we want to create the space for boot first. Click the Ok button after finished:


4) Just do exactly the same like Step 3, but this time choose the SDB instead. Press Ok when done:


5) Next is the swap partition for the RAID. Click the New button and choose the File System Type to Software RAID. Choose SDA first for the Allowable Drives. Then please enter the Size for your swap. Remember, the swap size is always double from your total psychical RAM. Since mine was running under 512MB, then I’ll put 1024MB as my swap size. Click the Ok button to proceed:


6) Do follow Step 5 but select SDB for the Allowable Drives. Click Ok to continue:


7) Next is to create the partition for root. Select the Software RAID from the File System Type. Then select SDA first for the Allowable Drives. But this time, choose the Fill All Available Space option and click the Ok button:


8 ) Just follow the same step just like Step 7, but this time choose the SDB instead. Click the Ok button to complete the partitioning:


9) Upon finishing the last partitioning, the hard disk layout should looks like below. Click on the RAID button to proceed:


10) Now we will start creating the RAID device. Type /boot in the Mount Point. Select RAID1 for the RAID Level. Inside the RAID Members, please make sure you selected the right partition for the boot. From the list, just select the SDA1 and SDB1. Click Ok to create the boot partition:


11) Next is to create the RAID device for swap. Select the File System Type to Swap. Then the RAID Level is set to RAID1. Don’t forget to select the right RAID Members for the swap, which are SDA2 and SBD2. Click Ok button to save:


12) After that, now to set up the RAID device for root. Type / inside the Mount Point to indicate the root. Make sure to select the RAID Level to RAID1. By this time, the RAID Members should only left with SDA3 and SDB3, so just select both. Click Ok to complete the partitioning:


13) Below is the final screen of the partitions should looks like. If everything is correct, then press the Ok button to proceed with the installation:


14) When the CentOS installation has been completed and the server is rebooting for the first time, log into the server using the root. You can check the RAID status and progress by typing cat /proc/mdstat


15) By default, the GRUB boot loader only were installed in one of the hard disk only. If you forgot this step, your second hard disk can’t boot by itself. You need to copy the GRUB from the SDA to SDB. Just type grub and follow like below, line by line:

device (hd0) /dev/sda
root (hd0,0)
setup (hd0)
device (hd1) /dev/sdb
root (hd1,0)
setup (hd1)


16) Please take note that the software RAID will be running under MDADM. This is a software that being developed to handle the RAID procedure inside the server. You can type mdadm –help for further information

By the time you finished the Step 15, your software RAID is ready to go. Happy trying 😉

Leave a Reply