Merge branch 'upstream'
[automated-distro-installer] / fai / config / scripts / GRUB_PC / 10-setup
index 160dfa2e35fd05333a5b98a895b90e826818aa72..85e90d2d08b4f2822d41f42149c34ad16593e154 100755 (executable)
@@ -3,6 +3,7 @@
 
 error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
 
+set -x
 set -a
 
 # do not set up grub during dirinstall
@@ -25,29 +26,23 @@ 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
     GROOT=$($ROOTCMD grub-probe -tdrive -d $BOOT_DEVICE)
     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
-    cat > $target/boot/grub/device.map <<EOF
-(hd0)   $BOOT_DEVICE
-EOF
-    $ROOTCMD grub-install --no-floppy --modules=part_msdos $BOOT_DEVICE
-    if [ $? -eq 0 ]; then
-        echo "Grub installed on hostdisk $BOOT_DEVICE"
-    fi
-    rm $target/boot/grub/device.map
-
 else
     for dev in $BOOT_DEVICE; do
         GROOT=$($ROOTCMD grub-probe -tdrive -d $dev)