update to 31b795ca71189b326b80666076398f31aea4f2be
[automated-distro-installer] / fai / config / scripts / GRUB_PC / 10-setup
index c19d4fa0438cf5b8633afabb4961c62486bc5dba..cbff2d84b606f876be230e092bcdeaac8d91aa2a 100755 (executable)
@@ -27,22 +27,20 @@ fi
 
 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; s/(nvme.+?)p/$1/g; print }' /proc/mdstat); do
        echo Install grub on /dev/$device
        $ROOTCMD grub-install --no-floppy "/dev/$device"
     done
-
-elif [[ $GROOT =~ 'hostdisk' ]]; then
-    $ROOTCMD grub-install --no-floppy --modules=part_msdos $BOOT_DEVICE
-    if [ $? -eq 0 ]; then
-        echo "Grub installed on hostdisk $BOOT_DEVICE"
-    fi
-
 else
     $ROOTCMD grub-install --no-floppy "$GROOT"
     if [ $? -eq 0 ]; then