2 # support for GRUB version 2
4 error
=0; trap 'error=$(($?>$error?$?:$error))' ERR
# save maximum error code
9 # do not set up grub during dirinstall
10 if [ "$FAI_ACTION" = "dirinstall" ] ; then
13 # during softupdate use this file
14 [ -r $LOGDIR/disk_var.sh
] && .
$LOGDIR/disk_var.sh
16 if [ -z "$BOOT_DEVICE" ]; then
20 # disable os-prober because of #788062
21 ainsl
/etc
/default
/grub
'GRUB_DISABLE_OS_PROBER=true'
23 # skip the rest, if not an initial installation
24 if [ $FAI_ACTION != "install" ]; then
29 GROOT
=$
($ROOTCMD grub-probe
-tdrive -d $BOOT_DEVICE)
31 # handle /boot in lvm-on-md
32 _bdev
=$
(readlink
-f $BOOT_DEVICE)
33 if [ "${_bdev%%-*}" = "/dev/dm" ]; then
34 BOOT_DEVICE
=$
( lvs
--noheadings -o devices
$BOOT_DEVICE |
sed -e 's/^*\([^(]*\)(.*$/\1/' )
37 # Check if RAID is used for the boot device
38 if [[ $BOOT_DEVICE =~
'/dev/md' ]]; then
39 GROOT
=$
($ROOTCMD grub-probe
-tdrive -d $BOOT_DEVICE)
40 raiddev
=${BOOT_DEVICE#/dev/}
41 # install grub on all members of RAID
42 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
43 echo Install grub on
/dev
/$device
44 $ROOTCMD grub-install
--no-floppy "/dev/$device"
47 for dev
in $BOOT_DEVICE; do
48 GROOT
=$
($ROOTCMD grub-probe
-tdrive -d $dev)
49 $ROOTCMD grub-install
--no-floppy "$GROOT"
51 echo "Grub installed on $dev = $GROOT"