update to 31b795ca71189b326b80666076398f31aea4f2be
[automated-distro-installer] / fai / config / scripts / GRUB_EFI / 10-setup
index 2e39e2f42b14659b29fbc6d528e9b678d2891953..fa8dd514b3dd62997b8c70687f0ae12a8302d739 100755 (executable)
@@ -33,28 +33,29 @@ if [ $FAI_ACTION != "install" ]; then
     exit $error
 fi
 
-$ROOTCMD grub-mkdevicemap --no-floppy
 GROOT=$($ROOTCMD grub-probe -tdrive -d $BOOT_DEVICE)
 
+# handle /boot in lvm-on-md
+_bdev=$(readlink -f $BOOT_DEVICE)
+if [ "${_bdev%%-*}" = "/dev/dm" ]; then
+  BOOT_DEVICE=$( lvs --noheadings -o devices $BOOT_DEVICE | sed -e 's/^*\([^(]*\)(.*$/\1/' )
+fi
 
 # Check if RAID is used for the boot device
 if [[ $BOOT_DEVICE =~ '/dev/md' ]]; then
     raiddev=${BOOT_DEVICE#/dev/}
     # install grub on all members of RAID
-    for device in `LC_ALL=C perl -ne 'if(/^'$raiddev'\s.+raid\d+\s(.+)/){ $_=$1; s/\d+\[\d+\]//g; print }' /proc/mdstat`; do
+    for device in $(LC_ALL=C perl -ne 'if(/^'$raiddev'\s.+raid\d+\s(.+)/){ $_=$1; s/\d+\[\d+\]//g; print }' /proc/mdstat); do
        echo Install grub on /dev/$device
        $ROOTCMD grub-install --no-floppy --force-extra-removable "/dev/$device"
     done
 
-elif [[ $GROOT =~ 'hostdisk' ]]; then
-    cat > $target/boot/grub/device.map <<EOF
-(hd0)   $BOOT_DEVICE
-EOF
+elif [[ $BOOT_DEVICE =~ '/dev/loop' ]]; then
+    # do not update vmram when using a loop device
     $ROOTCMD grub-install --no-floppy --force-extra-removable --modules=part_gpt --no-nvram $BOOT_DEVICE
     if [ $? -eq 0 ]; then
         echo "Grub installed on hostdisk $BOOT_DEVICE"
     fi
-    rm $target/boot/grub/device.map
 
 else
     $ROOTCMD grub-install --no-floppy --modules=part_gpt "$GROOT"