Sample Header Ad - 728x90

I need help with packer (vagrant box) build(er) config/scripts so UEFI boot order is properly configured

1 vote
1 answer
422 views
**Setup** *Host*
OS: Manjaro XFCE x86_64
Apps: packer (plugins: virtualbox-iso),
*Guest*
OS:                Arch Linux  
Hypervisor:        Virtualbox 
Architecture:      x64
I have built a Vagrant box using Packer. My goal is to have the VMbox run one application like a docker container app, but since the application needs to use partitioning, I can't use docker for it without some risk that I'm trying to avoid. A vagrant box is a self-customized virtual machine. This way other people can have the same OS setup as you do yourself. I've built one for Virtualbox, but I'm not completely there yet. One of the things that I want in my VM is for it to be modern, so I want to use of UEFI, but I haven't been able to fully figure out, how to construct it for VMs. Which is why I'm confronted with this issue:
UEFI fails to load properly. BdsDxe: failed to load Boot0001 "UEFI VBOX Harddisk"
See below in image: enter image description here I've noticed that checking the boot order given for my box does not correspond what virtualbox can find, so I'm wondering why this is. I have only two options in the Virtualbox of which the former is the harddisk boot, which it can't find and the second is starting some kind of network boot? I just want to get into GRUB. enter image description here During the building of the vagrant box, I call efibootmgr to see what my Disk should be giving as it's boot order. *output of efibootmgr*
SE_bastille-installer-box.virtualbox-iso.archlinux: ==> bootloader.sh: Check boots..
SE_bastille-installer-box.virtualbox-iso.archlinux: BootCurrent: 0001
SE_bastille-installer-box.virtualbox-iso.archlinux: Timeout: 0 seconds
SE_bastille-installer-box.virtualbox-iso.archlinux: BootOrder: 0005,0000,0002,0003,0004
SE_bastille-installer-box.virtualbox-iso.archlinux: Boot0000* UiApp   FvVol(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(462caa21-7614-4503-836e-8ab6f4662331)
SE_bastille-installer-box.virtualbox-iso.archlinux: Boot0002* UEFI VBOX HARDDISK    PciRoot(0x0)/Pci(0xf,0x0)/SCSI(0,0){auto_created_boot_option}
SE_bastille-installer-box.virtualbox-iso.archlinux: Boot0003* UEFI PXEv4 (MAC:0800277E9510)   PciRoot(0x0)/Pci(0x3,0x0)/MAC(0800277e9510,1)/IPv4(0.0.0.00.0.0.0,0,0){auto_created_boot_option}
SE_bastille-installer-box.virtualbox-iso.archlinux: Boot0004  EFI Internal Shell   FvVol(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(7c04a583-9e3e-4f1c-ad65-e05268d0b4d1)
SE_bastille-installer-box.virtualbox-iso.archlinux: Boot0005* GRUB   HD(1,GPT,1e8f8680-99c0-4c28-b83a-eb601805d4c4,0x800,0x96000)/File(\EFI\GRUB\grubx64.efi)
Below is the script that builds the boot loader. *scripts/bootloader.sh*
#!/usr/bin/env bash

. /root/vars.sh

NAME_SH=bootloader.sh

# stop on errors
set -eu

echo "==> ${NAME_SH}: Installing grub packages.."
/usr/bin/arch-chroot ${ROOT_DIR} /usr/bin/pacman --noconfirm -S edk2-ovmf efibootmgr grub os-prober >/dev/null

echo "==> ${NAME_SH}: Pre-configure grub.."
/usr/bin/arch-chroot ${ROOT_DIR} sed -i 's/#GRUB_DISABLE_OS_PROBER/GRUB_DISABLE_OS_PROBER/' /etc/default/grub

echo "==> ${NAME_SH}: Installing grub.."
/usr/bin/arch-chroot ${ROOT_DIR} grub-install --target=x86_64-efi --efi-directory=${ESP_DIR} --bootloader-id=GRUB &>/dev/null
/usr/bin/arch-chroot ${ROOT_DIR} grub-mkconfig -o /boot/grub/grub.cfg &>/dev/null

echo "==> ${NAME_SH}: Check boots.."
if [[ $PACKER_BUILDER_TYPE == "virtualbox-iso" ]]; then
  /usr/bin/arch-chroot ${ROOT_DIR} efibootmgr --delete-bootnum --bootnum 1
fi
/usr/bin/arch-chroot ${ROOT_DIR} efibootmgr
The EFI file can be found in shell, so I'm doing at least something correctly. enter image description here And I can add the boot option so that it will work, but I want box to work.. well.. out of the box! My packer build file https://raw.githubusercontent.com/safenetwork-community/SE_bastille-installer-box/arch/bib-base/SE_bastille-installer-box.pkr.hcl What am I doing wrong?
Asked by Folaht (1156 rep)
Jun 19, 2023, 05:38 AM
Last activity: Aug 1, 2023, 12:44 AM