From cf27c200c4010fc8085b49f1160b552d5970d684 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sat, 28 Feb 2015 14:50:58 +0000 Subject: vyatta-cfg-system: ensure grub is installed to the raid slave members When the system is installed in a raid configuration, grub is installed to the raid device instead of to the individual slave drives, resulting in a failure to boot after installation. This commit identifies the slave drives and ensures grub is installed to all of them (rather than just the primary), resulting in a system that will boot following a primary drive failure. Bug #106 http://bugzilla.vyos.net/show_bug.cgi?id=106 --- scripts/install/install-postinst-new | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/install/install-postinst-new b/scripts/install/install-postinst-new index e8a84c5e..11cf788e 100755 --- a/scripts/install/install-postinst-new +++ b/scripts/install/install-postinst-new @@ -105,8 +105,11 @@ copy_config () { # setup grub on the boot sector of a user selected drive install_grub () { grub_inst_drv='' + raid_slaves='' + if [ ${INSTALL_DRIVE:0:2} == "md" ]; then - grub_inst_drv=$INSTALL_DRIVE + raid_slaves=`ls /sys/block/${INSTALL_DRIVE}/slaves` + grub_inst_drv="md raid" fi mkdir -p $grub_root/boot/grub @@ -123,11 +126,25 @@ install_grub () { echo -n "Setting up grub: " lecho "Setting up grub..." - # Install grub in the boot sector of the primary drive + # Install grub in the boot sector of the primary drive, or if the installation + # target is a raid setup, then install it into the boot sector of all slave + # members. + progress_indicator start - output=$(grub-install --no-floppy --recheck --root-directory=$grub_root \ - /dev/$grub_inst_drv 2>&1) - lecho "$output" + + if [[ $grub_inst_drv == "md raid" ]]; then + for slave in $raid_slaves; do + grub_inst_drv=${slave:0:3} + output=$(grub-install --no-floppy --recheck --root-directory=$grub_root \ + /dev/$grub_inst_drv 2>&1) + lecho "$output" + done + else + output=$(grub-install --no-floppy --recheck --root-directory=$grub_root \ + /dev/$grub_inst_drv 2>&1) + lecho "$output" + fi + progress_indicator stop output=$(/opt/vyatta/sbin/vyatta-grub-setup $grub_setup_args \ -- cgit v1.2.3