2 # support for GRUB version 2
4 error
=0; trap 'error=$(($?>$error?$?:$error))' ERR
# save maximum error code
8 # do not set up grub during dirinstall
9 if [ "$FAI_ACTION" = "dirinstall" ] ; then
12 # during softupdate use this file
13 [ -r $LOGDIR/disk_var.sh
] && .
$LOGDIR/disk_var.sh
15 if [ -z "$BOOT_DEVICE" ]; then
19 # disable os-prober because of #788062
20 ainsl
/etc
/default
/grub
'GRUB_DISABLE_OS_PROBER=true'
22 # skip the rest, if not an initial installation
23 if [ $FAI_ACTION != "install" ]; then
28 $ROOTCMD grub-mkdevicemap
--no-floppy
29 GROOT
=$
($ROOTCMD grub-probe
-tdrive -d $BOOT_DEVICE)
32 # Check if RAID is used for the boot device
33 if [[ $BOOT_DEVICE =~
'/dev/md' ]]; then
34 raiddev
=${BOOT_DEVICE#/dev/}
35 # install grub on all members of RAID
36 for device
in `LC_ALL=C perl -ne 'if(/^'$raiddev'\s.+raid\d+\s(.+)/){ $_=$1; s/\d+\[\d+\]//g; print }' /proc/mdstat`; do
37 echo Install grub on
/dev
/$device
38 $ROOTCMD grub-install
--no-floppy "/dev/$device"
41 elif [[ $GROOT =~
'hostdisk' ]]; then
42 cat > $target/boot
/grub
/device.map
<<EOF
45 $ROOTCMD grub-install
--no-floppy --modules=part_msdos
$BOOT_DEVICE
47 echo "Grub installed on hostdisk $BOOT_DEVICE"
49 rm $target/boot
/grub
/device.map
52 $ROOTCMD grub-install
--no-floppy "$GROOT"
54 echo "Grub installed on $BOOT_DEVICE = $GROOT"