How to make a RAID1 Linux system boot from either drive

By jbayer - Last updated: Tuesday, November 2, 2010 - Save & Share - Leave a Comment

There is a problem with Ubuntu and other distributions when you set up a system with a RAID-1 setup.  The installer only installs Grub to the first drive.  If the first drive fails, then even if all your data is on the second drive you won’t be able to boot from it.

The following script fixes this problem by installing Grub to both drives.  Just paste it into a file, save it, make it executable and run it.

This script only works for Grub, not Grub-2

The only thing you may need to change is HDDEV, it needs to be the first two letters of the device name.  It is usually either “sd” or “hd”

#! /bin/bash
echo “device (hd0) /dev/”$HDDEV”a” >$f
echo “root (hd0,0)” >>$f
echo “setup (hd0)” >>$f
echo “device (hd0) /dev/”$HDDEV”b” >>$f
echo “root (hd0,0)” >>$f
echo “setup (hd0)” >>$f
echo “quit” >>$f
grub –no-floppy <$f
rm $f
exit 0

Posted in Administration, Bash, Open Source • • Top Of Page

Write a comment