SOFTWARE RAID - THE PROPER WAY
AUTHOR - Nic Maurel

In the past people would use scsi disks with a raid controller, where the raid controller would handle the load. In recent times, with the improvement of drive speeds (Sata, AHCI), and CPU speeds (dual core, hyper threading) , the overhead of having software raid has become a more viable solution. In this short paper I am going to show you how to do software mirroring (raid 1) on a Linux system (tested on Redhat AS 3 and Fedora Core 4). Our goal = Total redundancy, OS and Files mirrored using software raid

What do we need?
1) PC with 2 hard disks of similar sizes. Eg 2 x 20 gig disks (IDE or SATA)
2) Fedora core 4 installation disk

When installing one must create the partitions in the same order on both disks, for ease of administration, and don't forget to specify raid 1 for mirroring.
PLEASE NOTE: All these partitions must be created as SOFTWARE RAID partitions. They can be created after the install but I tend to create them during the installation with disk druid. For example..

Partition Size       Disk 1            Disk 2
   18000MB        /  hda1 or sda1     / hdb1 or sdb1         (please note hd = IDE and sd = sata)
   1000MB        swap hda2 or sda2    swap hdb1 or sdb2    (May vary depending on physical mem)
   100MB        /boot hda3 or sda3    /boot            (Good practice is 100MB)

Now we create our software raid device md. One would need to create as many software raid devices as there are partitions created. In this case we have created 3 partitions thus we would need to create 3 md devices

md0 - /boot
md1 - swap
md2 - /
          
Once this has been done, we would now be ready to install the OS. I am not going to talk you through this as this is not a document on how to install Redhat or fedora, so we will skip ahead to the end of the install and your system should now be setup to run Redhat or fedora.

Now here's the trick! Most people will stop here and think the machine is totally mirrored, but what they actually miss out on is the fact that the grub mbr is actually installed on only one of the drives. This means that if the drive with the mbr (hda or sda) goes faulty then the system won't boot with the second disk (hdb or sdb). This doesn't sound very raid like at all! Effectively we have a mirroring system that will only boot on one of the disks.

There is two ways to get around this:

1) Add in a third disk add your mbr and grub there and the system will happily boot, but this isn't an ideal solution as it is not cost effective and if the 3rd disk goes down, you will have to fork out for another disk

2) Alternatively, tell grub after the installation of the system to install the mbr on the second disk (hdb or sdb).
Now this is the part where I show you how to do number 2, but I must warn you do not play around too much with grub as you can prevent your machine from booting with the wrong parameters.

Alrighty then heres how we do it
Log in as root onto your system and do the following, (Please see bottom for explanation)
    
 [root@bob root]# grub
 
1)    grub> find /grub/stage1
      (hd0,0)
      (hd1,0)

2)    grub> device (hd0) /dev/sdb

3)    grub> root (hd0,0)
      Filesystem type is ext2fs, partition type 0xfd

4)    grub> setup (hd0)
      Checking if "/boot/grub/stage1" exists... no
      Checking if "/grub/stage1" exists... yes
      Checking if "/grub/stage2" exists... yes
      Checking if "/grub/e2fs_stage1_5" exists... yes
      Running "embed /grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.
    succeeded
      Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub
    .conf"... succeeded
    Done.

5)    grub> quit

 
1) Shows where the grub setup files are located (/boot is the root partition for grub)
2) Specifies secondary disk as primary disk ( /dev/sdb for sata and /dev/hdb for IDE - this may vary depending on where your drive is situated)
3) Specify where your /boot partition resides
4) Setup grub on secondary disk (note: stage one doesn't exist)
5) quit or exit

Final Words

Well, that's about it, we now have a proper software raid mirroring solution to use at our disposal. Feel free to try taking out one disk at a time to see if both disks boot independently. Isn't Linux amazing! Anyway I hope you have enjoyed this, and don't forget experimenting is a good thing!