First, it is my opinion that you shouldst use hardware RAID of some form. Software RAID, in my opinion, is best used to stripe volumes between multiple hardware RAID controllers which do not support spanning.
My opinion aside, will the server still boot? Yes! … if it is configured correctly.
The Multiple Disk (md) infrastructure in Linux is quite flexible, and there are many articles available for its use. When configuring a server to recover from a failed disk-0 in a RAID mirror, your boot partition should be mirrored using metadata version 1.0. Version 1.0 places metadata at the end of the device, whereas 1.1 metadata is at the front of the device. Since metadata is at the end of the disk, GRUB (or whatever bootloader you prefer) can still read your boot images.
Lets say you have a server with (at least) three disk bays. Disk-0 in bay1 fails, so you add a 3rd disk in bay3 and rebuild the volume. The process might look something like thos:
## Transfer the boot sector # dd if=/dev/sdb count=1 of=/dev/sdc ## Reread the partition table # blockdev --rereadpt /dev/sdc ## Add the hot spare # mdadm --add /dev/md0 /dev/sdc1 # mdadm --add /dev/md1 /dev/sdc2 ## Fail the bad disk: # mdadm --fail /dev/sda1 # mdadm --fail /dev/sda2
Now disk-0 (sda) is failed, and the mirror is rebuilding on sdb/sdc. If you boot, what will happen? Will it load the mirror correctly? Will the kernel respect which disk is in the mirror? We recently had a real-life scenario where a CentOS 6 server was in production and could not be rebooted, but we needed to know if the server would come up if there was a reboot. Disk-0 was dying (but not completely dead yet).
Test to make certain
- If disk1 may not contain the right boot sector, so when disk0 is removed, will the server boot?
- If disk0 isn’t removed and the server is rebooted, will it boot? If it does come up, will the kernel respect that disk0 is, indeed, failed?
The answer to both of these questions, at least in theory, is yes.
To be sure, I simulated the two failure scenarios above and everything worked without intervention. This was the order of things, disks are named disk0, disk1, disk2:
- Install CentOS 6 on mirrored boot and lvm partitions across two disks.
- Add disk2, copy the bootsector over, and add as a hot spare.
- Fail disk0, let the hot spare rebuild.
- The system loads the bootsector from disk0 because it is the first physical disk serviced by BIOS.
- The kernel boots and auto-detects the RAID1 mirrors on disk1 and disk2, ignoring disk0 which we failed (good!) This verifies question #1.
- Physically remove disk0; BIOS will see disk1 as the first BIOS drive.
- The system loads the bootsector from disk1 because it is the first physical disk serviced by BIOS.
- The kernel boots and initrd auto-configures the RAID1 mirrors on disk1 and disk2. Thus validates question #2.
Of course you would expect the above to work—but its always best to test and understand exactly how your disk-volume software will act in various failure scenarios when working in a production environment. “I think so” isn’t good enough to go on—you must know.
So, if you’re booting from software RAID, you can usually trust that your data is safe. Sometimes a failed disk will hang IOs to the device. I have seen servers completely freeze when this happens while it attempts to retry the IO over-and-over-and-over. This is where hardware RAID can really save you; the hardware controller would have timed-out the RAID member disk, failed it, and continued with very little (if any) interruption.
Linux Raid controller tips
- Be careful of “softraid” chipsets out there, not all RAID is real-RAID. My favorite controllers in order or preference are 3ware, Areca, and LSI. The PERC 7xx series are ok too, but I wouldn’t trust a PERC 2xx.
- If you use LSI go with a higher-end controller for better performance and less fuss. Generally speaking, I’ve had great success with LSI controllers that have onboard cache memory (even if you don’t use it in write-back mode). Cacheless LSI controllers have created problems more times than I care to recall.
- Check the RAID-levels that the card supports. If the controller supports RAID-5 or -6, it is probably a better controller even if you only use the RAID-10 functionality.
- Also of note, LSI now owns 3ware and uses LSI chips in 3ware’s hardware. I have since used LSI-built 3ware cards and they still have the simple and robust 3ware feel. I have a feeling that LSI will keep the 3ware brand for some time to come.