On-the-fly Create RAID 1 on RH/Fedora

Create the partitions
fdisk /dev/hda
fdisk /dev/hdc

For example, create 2 partition on 2 harddrive each 10GB and the result is
/dev/hda2
/dev/hda5

/dev/hdc2
/dev/hdc5


Create a block device
mknod /dev/md0 b 9 0
mknod /dev/md1 b 9 1

Assign the device which want to run the raid
mdadm –create /dev/md0 –level=1 –raid-devices=2 /dev/hda2 /dev/hdc2
mdadm –create /dev/md1 –level=1 –raid-devices=2 /dev/hda5 /dev/hdc5

Getting the raid status
mdadm –detail /dev/md0

You’ll see either clean or recovering…

Make the filesystem
mkfs /dev/md0
mkfs /dev/md1

Ready for mount
mount /dev/md0 /where/you/go
mount /dev/md0 /where/you/go

Add/Modify /etc/fstab
/dev/md0 /where/you/go ext3 defaults 1 2
/dev/md0 /where/you/go ext3 defaults 1 2

Modify /etc/mdadm.conf
DEVICE /dev/hda2 /dev/hda5 /dev/hdc2 /dev/hdc5
MAILADDR root
ARRAY /dev/md0 devices=/dev/hda2,/dev/hdc2
ARRAY /dev/md1 devices=/dev/hda5,/dev/hdc5

Update initrd image
If you don’t, the block device will disappear once you reboot

cd /boot
mkinitrd initrd-2.6.9-1.667-2.img 2.6.9-1.667

mkinitrd usages
mkinitrd

Update grub.conf
Copy the current boot parms, add a new entry and modify the initrd to
initrd /initrd-2.6.9-1.667-2.img

Reboot
Make sure the new raid device is clean before you reboot.
mdadm –detail /dev/md0
mdadm –detail /dev/md1