GRUB EFI blues - Debian 9/FAI 5.3.6

Markus Köberl markus.koeberl at tugraz.at
Thu Apr 19 11:27:38 CEST 2018


On Tuesday, 17 April 2018 15:28:56 CEST Bob Apodaca wrote:
> I have a Supermicro X11SAE motherboard with an M.2 SATA drive that requires
> UEFI to boot. I've created a bootable USB drive, I've changed the BIOS
> settings to use UEFI and I can boot and appear to install the system.
> However, the system will not boot after the install is completed and the
> system does not recognize the drive.

I have some cheap laboratory hosts from Lenovo with M.2 NVME drive.
I was able to install debian stretch in legacy mode and boot it. But it only worked if I a manually chose the disk during boot.
Last year I got a config running for installing a dual boot system (windows 10 + debian stretch).
The work was based on some work I did years before. Therefore I do not know if my documentation is complete.

I do not have a disk_config laying around. I am using a hook to get it right because i am using ntfsclone to copy the windows 10 including the efi partition with everything necessary for windows 10.

> I think the first issue is FAI is setting the GRUB_PC class instead of the
> GRUB_EFI class and I'm not sure why.

I did not find a solution to automatically detect if uefi boot is supported and also booted via uefi mode.
My workaround is to have a grub menu for pxe boot via uefi with 2 entries for legazy and uefi mode.

on the client:
disable secure boot

on the fai server:

$ apt-get install grub-efi-amd64-bin
$ grub-mknetdir --net-directory /srv/tftp/fai/ --subdir efi
$ cp /usr/share/grub/unicode.pf2 /srv/tftp/fai/efi

$ cat /srv/tftp/fai/efi/grub.cfg
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
set timeout=5
# for debug:
#set pager=1
#set debug=all

insmod efi_gop
insmod efi_uga
if loadfont ${prefix}/fai/unicode.pf2
then
    insmod gfxterm
    set gfxmode=auto
    set gfxpayload=keep
    terminal_output gfxterm
fi

menuentry "Install Debian stretch on UEFI BIOS" {
    linux  (tftp)vmlinuz-4.9.0-6-amd64  ip=dhcp  root=nfs:129.27.140.248:/srv/fai/nfsroot rootovl  FAI_FLAGS=verbose,sshd,createvt,reboot,salt FAI_CONFIG_SRC=git+https://gitint.spsc.tugraz.at/sysadmin/fai-config.git#stretch FAI_ACTION=install FAI_USE_UEFI_BIOS
    initrd (tftp)initrd.img-4.9.0-6-amd64
}

menuentry "Install Debian stretch on legacy BIOS" {
    linux  (tftp)vmlinuz-4.9.0-6-amd64  ip=dhcp  root=nfs:129.27.140.248:/srv/fai/nfsroot rootovl  FAI_FLAGS=verbose,sshd,createvt,reboot,salt FAI_CONFIG_SRC=git+https://gitint.spsc.tugraz.at/sysadmin/fai-config.git#stretch FAI_ACTION=install
    initrd (tftp)initrd.img-4.9.0-6-amd64
}


you need to configure the DHCP server: https://lists.uni-koeln.de/pipermail/linux-fai/2014-February/010294.html


and the fai pxe template:
$ cat /srv/tftp/fai/pxelinux.cfg/uefi 
default fai-generated

label fai-generated
kernel vmlinuz-4.9.0-6-amd64
append initrd.img-4.9.0-6-amd64 ip=dhcp  root=nfs:129.27.140.248:/srv/fai/nfsroot rootovl  FAI_FLAGS=verbose,sshd,createvt,reboot,salt FAI_CONFIG_SRC=git+https://gitint.spsc.tugraz.at/sysadmin/fai-config.git#stretch FAI_ACTION=install FAI_USE_UEFI_BIOS



in the fai-config space i have

11-base-classes:
# UEFI BIOS supported
if [ $(dmidecode | grep "UEFI is supported" >/dev/null; echo $?) -eq 0 ]; then
    # UEFI BIOS not in legacy mode
    # (manually using kernel option FAI_USE_UEFI_BIOS)
    if [ $(cat /proc/cmdline | grep "FAI_USE_UEFI_BIOS" > /dev/null; echo $?) -eq 0 ]; then
        echo GRUB_UEFI
    # use legacy mode
    else
        echo GRUB_PC
    fi
# no UEFI support
else
    echo GRUB_PC
fi


package_config/DEBIAN:
PACKAGES install GRUB_PC
grub-pc grub-legacy- lilo-

PACKAGES aptitude GRUB_UEFI
grub-efi grub-pc- grub-legacy- lilo-
os-prober


scripts/GRUB_UEFI/10-setup:
#!/bin/bash

error=0 ; trap "error=$((error|1))" ERR

set -a

[[ $FAI_ACTION != "softupdate" ]] || exit 0

if [ -z "$BOOT_DEVICE" ]; then
    exit 189
fi

modprobe efivars

# force target arch in case we did not boot using uefi pxe boot
if ifclass AMD64; then
    GRUB_TARGET_ARCH="--target=x86_64-efi"
fi

$ROOTCMD grub-install $GRUB_TARGET_ARCH $BOOT_DEVICE
$ROOTCMD update-grub

# update boot order
# get number for debian
EFI_DEBIAN_NUMBER=`$ROOTCMD efibootmgr | awk 'match($0,/Boot(.*)\* debian/,var) {print var[1]}'`
# get order into array
EFI_BOOT_ORDER=(`$ROOTCMD efibootmgr | awk 'match($0,/BootOrder: (.*)/,var) {print var[1]}' | tr -t ',' ' '`)

$ROOTCMD efibootmgr -o ${EFI_DEBIAN_NUMBER},`echo ${EFI_BOOT_ORDER[@]/$EFI_DEBIAN_NUMBER} | tr -t ' ' ','`

exit $error



I hope this will help and I did not oversee anything. I am using fai 5.6 but it also worked with older versions.


regards
Markus Köberl
-- 
Markus Koeberl
Graz University of Technology
Signal Processing and Speech Communication Laboratory
E-mail: markus.koeberl at tugraz.at


More information about the linux-fai mailing list