Configuring grub loader to boot from second drive of RAID1

The problem is, the grub boot loader doesn’t know about the software RAID, so it only installs the boot loader on the first drive. Which is good enough, unless the first drive is the one which fails after a few years.If the first drive fail or removed, the bootloader was unable to read its configuration leaving the system in an unusable and un-bootable state. All data was mirrored and RAIDed properly, only the bootloader was affected.

So here, the GRUB boot loader will be configured in such a way that the system will still be able to boot if one of the hard drives fails (no matter which one).

Preparing GRUB (Part 1)

We must install the GRUB boot loader on the second hard drive /dev/sdb: Follow these steps

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

grub>
setup (hd1)
grub> setup (hd1)
 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 (hd1)”…  15 sectors are embedded.
succeeded
 Running “install /grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/grub/stage2 /grub/menu.lst”… succeeded
Done.

grub>
quit
Now, back on the normal shell.

Preparing GRUB (Part 2)

We are almost done now. Now we must modify /boot/grub/menu.lst again. Right now it is configured to boot from /dev/sda (hd0,0). Of course, we still want the system to be able to boot in case /dev/sda fails. Therefore we copy the first kernel stanza (which contains hd0), paste it below and replace hd0 with hd1. Furthermore we comment out all other kernel stanzas so that it looks as follows:
vi /boot/grub/menu.lst
[…]
## ## End Default Options ##

title Debian GNU/Linux, kernel 2.6.18-4-486 RAID (hd0)
root (hd0,0)
kernel /vmlinuz-2.6.18-4-486 root=/dev/md0 ro
initrd /initrd.img-2.6.18-4-486
savedefault

title Debian GNU/Linux, kernel 2.6.18-4-486 RAID (hd1)
root (hd1,0)
kernel /vmlinuz-2.6.18-4-486 root=/dev/md0 ro
initrd /initrd.img-2.6.18-4-486
savedefault

In the same file, there’s a kopt line; check it have the raid device mentioned. (don’t remove the # at the beginning of the line!):
[…]
# kopt=root=/dev/md0 ro
[…]

Afterwards, update your ramdisk. Run,

update-initramfs -u

Now reboot your box!!
And finally your boot loader will looks like this – ( and try to boot from both drive ( hd0, hd1)

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s


%d bloggers like this: