Setting up GRUB to boot from both disks of mirrored RAID
Many people use mirrored RAID (also known as 'RAID 1') to protect themselves against data loss caused by hard disk failure. Sometimes, you even want GRUB to boot from the secondary hard disk in case the primary fails to keep the system up and running. This is however not as easy as one might think...
GRUB keeps track of the hard disks currently available on your system, on most distributions you can find this information in /boot/grub/device.map. You might have a file like this:
hopper:~# cat /boot/grub/device.map (hd0) /dev/sda (hd1) /dev/sdb
Of course you can install GRUB to /dev/sdb (which is hd1), but obviously GRUB will be confused if /dev/sda fails and hd1 becomes hd0. Most likely, it will complain about a failing hard disk at boot time:
GRUB Hard Disk Error
In this case, you want to install GRUB to /dev/sdb and have sdb also mapped to hd0:
hopper:~# cat /boot/grub/device.map (hd0) /dev/sda (hd0) /dev/sdb hopper:~# grub-install /dev/sdb The drive (hd0) is defined multiple times in the device map /boot/grub/device.map
GRUB doesn't accept this duplicate definition (which is indeed incorrect), so you need to configure things by hand:
hopper:~# grub grub> device (hd0) /dev/sdb grub> root (hd0,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd0) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded Done. grub> quit
Now, /dev/sda and /dev/sdb are configured as hd0 and the system remains bootable if /dev/sda fails.
Assumptions about partitions
The above information only works if your boot filesystem can be found on both /dev/sda1 and /dev/sdb1. If you have /boot on e.g. /dev/sda5 and /dev/sdb5, you'll have to replace root (hd0,0) with something more applicable for your specific configuration.