My experience with RAID on CentOS

One of my servers went down recently. Another chance for my brother to dig on Linux. “Linux sucks” he says but don’t be fooled by the statement. He is a big fan boy of Mac but is not a Linux hater, and in so many situations has recommended Linux. He just loves bugging me. Well back to the story. The power supply seemed to have given problems and the hard disk on which the root laid got corrupted and there by the system crashed. For those Linux skeptics, hardware problem not software. So now I had to come up with a solution to see that if the hard disk failed I should be able to boot of with another. RAID!!

For those who don’t know what RAID is, its a Redundant Array of Inexpensive Disks, and more recently people are referring it as Redundant Array of Independent Disks. Basically its a method to combine disks together or to make redundant copies of disks automatically, more like an automated backup. For more information look at the article on Wikipedia.

So I bought two 500 GB hard disks and two 1.5 TB hard disks. The first two I decided to have the /boot and the / partitions. The 1.5 TB was for the /var partition. Started the installation of CentOS 5.2. The system detected my disks as:

/dev/sda , /dev/sdc 500 GB

/dev/sdb, /dev/sdd 1.5 TB

I created one RAID partition on each of the 500 GB HDD, 200MB and created it as the /boot partition with RAID level 1 (Mirroring). Created another on each of the HDDs made it as LVM (logical volume manager), again RAID level 1. I created the swap, /, /home in the LVM. Then created another RAID on each of the 1.5 TB and created a LVM out of that. /var found itself in this LVM.

Thus I had two 500 G mirroring each other and two 1.5 T mirroring. Installation took a while and every thing went smooth. After setting up the basic necessities I tried to test the implementation. Pulled out the second 500 G /dev/sdc the system worked like a charm. Pulled out the second 1.5 T and again the system worked. It was getting late and had to go hit the bed. Went home hoping the test would work well the other way round as synchronization of the RAID was taking a long time when I fixed the disks again.

Next morning, back at work at 7 in the morning. Boss came over at 9 and we tried to test it. I unplugged the main 500G HDD and started the system. FLOP! The system did not boot, got stuck in GRUB. All the system showed was


All efforts in vain I thought as my boss gave a cynical smile. I got a breather and resorted to consult the Gandalf of all search engines, Google. And  I was right to call it Gandalf, the solution popped up as the second entry. Linux Raid wiki! You can refer that for the instructions of creating your own RAID system.

From there I figured I had to configure the system to boot of from multiple devices. (refer the “Prepare to Boot” subdivision). I had to make GRUB understand that if the first disk, /dev/sda, failed it needed to use the second one, /dev/sdc. Executing these commands worked up fine.

grub --no-floppy <<EOF
root (hd0,0)
setup (hd0)
device (hd0) /dev/sdc
root (hd0,0)
setup (hd0)

It was testing time again. I unplugged the first HDD, /dev/sda, and booted. At last, the system booted into CentOS 5.3 (yeah, I updated it). I literally ran shouting out my boss’s name. All the cynical grin on his face was gone when he analysed it. Well he was happy, he needed a fail safe system.

Thus the server was up and all work returned to normal. Hope things work out. One never knows I might have to try RAID 5!

My experience with RAID on CentOS

4 thoughts on “My experience with RAID on CentOS

  1. I’ve recently been experimenting with RAID in Linux and so far I love it. The coolest part about RAID in Linux is the extreme flexibility, from some experimenting I’ve found that RAID 5 arrays are expandable in Linux. Also, when used with LVM RAID arrays can be combined to function as one large drive. Both of these features combined make for a enjoyable experience with RAID and are also great on the wallet by making the best use of available drives. If I were you I would probably stick to RAID 1 for the OS as RAID 5 write speeds are pretty slow and might degrade the OS’s performance. If any of your readers are interested I have a tutorial on how to setup software RAID 0, 1, 5, 6 or 10 array in Fedora 11 with a GUI (nice for the average person not familiar with Terminal).

  2. Arturo says:

    Nice article, I just setup up an array on a CentOS 5 following these steps and works fine, you know is there any way that the system show an alert when one disk fail?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s