Skip to content

DRAFT2: Fuse GRUB configuration into the EFI binary

Kareem Zarka requested to merge kzarka/oniro:2grub-merge into kirkstone

Updating two files in a safe, transactional manner is way, way harder than updating one. By having the grub.cfg file built-into GRUB binary we can avoid a lot of complexity without limiting anything relevant. Configure GRUB to have a built-in config file identical to the one we currently build in the oniro-grub-bootconf recipe. The existing file may "stay" if it is unused and this makes things easier for wic integration. Make sure to create a cleanup task if this happens..

On my second try to fuse grub.cfg into grub-efi I fail... I first made the recipe oniro-grub-bootconf install grub.cfg into ${DEPLOYDIR}. Then I made the recipe grub-efi-%bbappend depend on oniro-grub-bootconf in this way we wait till we have grub.cfg from DEPLOYDIR then we use it to embed the file into the binary After building the recipe and the image oniro-image-base the booting fails with the following error

BdsDxe: loading Boot0001 "UEFI QEMU QEMU HARDDISK " from PciRoot(0x0)/Pci(0x4,0x0)/Scsi(0x0,0x0)
BdsDxe: starting Boot0001 "UEFI QEMU QEMU HARDDISK " from PciRoot(0x0)/Pci(0x4,0x0)/Scsi(0x0,0x0)
Welcome to GRUB!

Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `#'.
Unknown command `if'.
note: found ONIRO_BOOT_PART=
Unknown command `else'.
error: cannot find boot partition, halting
runqemu - INFO - Cleaning up
runqemu - INFO - Host uptime: 106393.93

sadly yes I'm not able to boot.... I investigated what's the problem and I realise that after embedding the cfg into grub's image , the script gets ruined some lines are added to it and its breaking the boot... Note that If we go to the WORKDIR of grub-efi recipe we find the cfg file as it is with the correct expanded variables but if we go to workdir/image of the grub-efi recipe and we run the following command strings bootx64.efi we find that the file has some addetional # , and removes from lines But I'm still not sure why..

https://www.diffchecker.com/1g3BHMXd in this link we find the difference between both files

Signed-off-by: Kareem Zarka kareem.zarka@huawei.com

Merge request reports