Topic: Is it possible to chainload from grub 2 to bootmgfw.efi on an ISO?  (Read 59 times)

ErikW

  • Jr. Chef
  • **
  • Date Registered: Mar 2017
  • Posts: 19
I know that it is possible to chainload from grub 2 to the bootmgfw.efi file on a hard disk EFI System Partition.

What I am trying to do is create an ISO DVD that boots to grub 2 first on a 64-bit EFI system.  Then I would like grub 2 to have a menu choice to chainload bootmgfw.efi to start the Windows boot manager and load the BCD plus a WIM file from the ISO DVD.

There are a lot of different versions of the boot manager files for EFI, including two in efisys.bin and efisys_noprompt.bin, bootmgfw.efi, bootmgr.efi and bootx64.efi in the normal /efi/boot folder.

On an EFI ISO image (DVD or CD), the EFI System Partition is actually not part of the iso9660 filesystem.  The ESP in an ISO is actually a no-emulation boot image stored as an El-Torito boot option.  Essentially the boot image is a copy of a FAT filesystem containing the folder "\EFI\BOOT" and the EFI bootloader files for the OS, BOOTX64.EFI and possibly others for 32-bit, etc.  Windows provides two ESP filesystem images for ISO booting, efisys.bin and efisys_noprompt.bin.  One prompts to press a key, and one does not.  Opening either of those files with 7-zip shows that they just contain a "\EFI\BOOT" folder and one file "BOOTX64.EFI".  Those files are different from other copies with the same name, or other names.  They apparently magically figure out the CD device handle for the iso9660 filesystem.

One problem is that grub 2 does not assign a device name to that special ESP partition, even though you can access it in the EFI shell.  I got around that problem by extracting a copy of the BOOTX64.EFI file from  efisys_noprompt.bin and placing the file in the ISO filesystem with the name "cdboot.efi".

The problem that I can't seem to solve is that running any of the boot manager EFI files from anywhere other than the El-Torito filesystem image results in an "Unkonwn error" displayed by the boot manager, and it returns to the EFI shell or grub 2.  Since running it doesn't work from the EFI shell, I can understand why it doesn't work when grub 2 chainloads it.

So long as I use the actual El-Torito filesystem in the EFI shell to load/run boot manager, such as "FS1:\EFI\BOOT\BOOTX64.EFI" then boot manager runs fine and finds the BCD in "FS0:\EFI\MICROSOFT\BOOT\".  If I try to use the EFI shell to run "FS0:\EFI\MICROSOFT\BOOT\cdboot.efi" or any other file on the ISO filesystem then boot manager just gives me an error.  I've tried all the different flavors of boot manager EFI files and they all either display an error, or silently return to the EFI shell.

I also tried mounting the efisys_noprompt.bin filesystem image with the loop driver in grub 2.  I can see the same files as are in the El-Torito image.  If I try to chainload the "\EFI\BOOT\BOOTX64.EFI" file identical to what is in the El-Torito boot image, it doesn't work and gives me the exact same error as the other files.

I obviously can't look at the bootmgr code to see how it locates the ISO filesystem based on the El-Torito filesystem.  I did look at the grub 2 source, and it does some parsing of the EFI block device ID to create a device ID for a different CD "partition?".  grub 2 never actually mounts the El-Torito EFI System Partition, and grub 2 gets the rest of its files from the ISO filesystem.  The thing is that the grub 2 code is written so that it works when loaded from any CD "partition" and I can load grub 2 from "FS0:" or "FS1:" in the EFI shell.  grub 2 is also different than boot manager because grub uses its own filesystem drivers and talks to all devices as block devices.  grub 2 doesn't use the EFI filesystem drivers.  The Windows boot manager does seem to use the EFI filesystem drivers, and for ISO it seems to care which filesystem device is used to load it.

I've tried a few other experiments with something called "wimboot" and "iPXE" but neither of those seems to work correctly with EFI.  I got a "wimbootx64.efi" file from the AIO boot disk to chainload, but I can find no documentation on how to use it.  Loading it as a "linux" with "initrd" doesn't work, and chainloading doesn't seem to accept any parameters.  None of the documentation that I've found mentions chainloading "wimboot", only loading it as a linux image.

I've pretty much given up for the moment.  I am hoping that someone has already done this and knows how to do it.  So far all the advice I'm getting is for booting from USB or hard disk and doesn't work on an ISO image.  This problem is only booting from an ISO, reading a BCD file from the ISO, and using EFI.  Booting with a BIOS, I have no problem chainloading bootmgr from grub 2 or grub4dos.

For now, my DVD just boots directly into the Windows boot manager on EFI systems.  If I want to boot anything else, I have to use the EFI shell to boot from the "FS0:\boot\grub\grubx64.efi" file.

Here you can see my grub custom configuration file with the various attempts to chainload commented out.  There are blank lines separating the different methods, but none of them worked.  The "root" is set to device (cd0).

Code: [Select]
menuentry 'Windows 10 PE 64-bit and Paragon Hard Disk Manager 15' {
chainloader /efi/microsoft/boot/bootmgfw.efi
#
# chainloader /efi/boot/bootx64.efi
#
# chainloader /efi/microsoft/boot/cdboot.efi
#
# loopback loop /efi/microsoft/boot/efisys_noprompt.bin
# chainloader (loop)/efi/boot/bootx64.efi
#
# chainloader /bootmgr.efi
}
« Last Edit: November 03, 2020, 05:23:42 AM by ErikW »

 

Powered by EzPortal