diff -upr a/util/grub-install.in b/util/grub-install.in --- a/util/grub-install.in 2008-08-11 12:48:18.000000000 -0500 +++ b/util/grub-install.in 2008-08-11 12:48:32.000000000 -0500 @@ -187,6 +187,11 @@ convert () { # If not found, print an error message and exit. if test "x$tmp_drive" = x; then echo "$1 does not have any corresponding BIOS drive." 1>&2 + # If /boot is on a RAID device, provide more information + if mdadm --detail "$bootdir_device" >/dev/null 2>&1; then + echo "You can run grub-install on your RAID device [$bootdir_device]," 1>&2 + echo "or you can define [$1] in [$device_map]." 1>&2 + fi exit 1 fi @@ -410,6 +415,10 @@ if test -n "$tmp"; then exit 1 fi +# Get the root drive. +root_device=`find_device ${rootdir}` +bootdir_device=`find_device ${bootdir}` + # Check for INSTALL_DEVICE. case "$install_device" in /dev/*) @@ -431,10 +440,6 @@ case "$install_device" in exit 1 ;; esac -# Get the root drive. -root_device=`find_device ${rootdir}` -bootdir_device=`find_device ${bootdir}` - # Check if the boot directory is in the same device as the root directory. if test "x$root_device" != "x$bootdir_device"; then # Perhaps the user has a separate boot partition. @@ -524,11 +529,31 @@ fi sync # Now perform the installation. -$grub_shell --batch $no_floppy --device-map=$device_map <$log_file +if echo "$install_device" | grep -qs "^/dev/md[0-9]" 2>/dev/null; then + # installing to an md device; write an MBR to each disk in the RAID + echo -n > $log_file + for frdisk in $(mdadm --detail "$install_device" 2>/dev/null | \ + grep " active sync " 2>/dev/null | \ + sed "s/^.* active sync\s*//" 2>/dev/null \ + ); do + dev=$(echo "$frdisk" | sed "s/[0-9]\+$//") + echo "Installing GRUB to $dev as $install_drive..." + $grub_shell --device-map=/dev/null <>$log_file +device $install_drive $dev +root $install_drive +setup --stage2=$grubdir/stage2 --prefix=$grub_prefix $force_lba $install_drive +quit +EOF + done +else + # traditional case, normal grub installation + echo "Installing GRUB to $install_device as $install_drive..." + $grub_shell --batch $no_floppy --device-map=$device_map <$log_file root $root_drive setup $force_lba --stage2=$grubdir/stage2 --prefix=$grub_prefix $install_drive quit EOF +fi if ${xfs_frozen} ; then xfs_freeze -u ${grubdir}