iPXE discussion forum
chain load with EFI and file:/ URL - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: chain load with EFI and file:/ URL (/showthread.php?tid=10739)



chain load with EFI and file:/ URL - walteste - 2018-01-12 14:35

I want to use iPXE as a replacement for grub2 on a multiboot system. The goal is to have the BIOS boot in to the ipxe.efi which will read its configuration from a web server. The web server gives it a config file to for instance boot /EFI/redhat/grubx64.efi.

I am stuck at the point where I chainload another efi file. In the iPXE shell I get this:

Code:
iPXE:> imgload file:/EFI/redhat/grubx64.efi
file:/EFI/redhat/grubx64.efi... ok
iPXE> imgstat
grubx64.efi : 1050064 bytes [EFI]
iPXE> boot
Could not boot: No such device (http://ipxe.org/2c048097)

Apparently it can load the file but booting into it fails. Searching for hints using the error code has not gotten me far.

Is this the correct way to boot an EFI file from disk? Is this supported at all?


RE: chain load with EFI and file:/ URL - NiKiZe - 2018-01-12 18:22

Visiting the error url, in this case http://ipxe.org/2c048097 should give you good information about what is going on.
In this case not much is provided, but going in to the sourcecode shows that it tries to get a handle from "EFIIMAGE %p could not identify SNP device"

this seems to be a bug, but a workaround would probably be to open the interface, such as by using dhcp or ifopen net0 (but this requires that some kind of network interface was initialized)


RE: chain load with EFI and file:/ URL - walteste - 2018-01-15 08:55

(2018-01-12 18:22)NiKiZe Wrote:  this seems to be a bug, but a workaround would probably be to open the interface, such as by using dhcp or ifopen net0 (but this requires that some kind of network interface was initialized)

Running dhcp beforehand actually helped, it now boots into file:/etc/redhat/grubx64.efi but does not load grub.cfg. It seems to me that file:/ URIs are intended for loading things like iPXE scripts but are not completely implemented for chain loading.

It looks like the the environment is not set up correctly. If I try to load file:/etc/redhat/shim.efi, which is supposed to load grubx64.efi in the same directory, it fails:

Code:
dppath: shim.efi
path:    shim.efi
Failed to open grubx64.efi - Not Found
...

So again, is this supposed to actually work? Has anybody ever tried to chain load an EFI image from a local disk and succeeded?


RE: chain load with EFI and file:/ URL - NiKiZe - 2018-01-15 19:58

The file:// was intended to load files from disk,
Everything that iPXE loads gets put in it's virtual memory fs, so when grub or anything else loads that is what it has access to and it does not know that it was loaded from disk and what the relative path is to any of the files that was sitting next to it.

So no the way you are trying to use it is not what it was designed for.

You could try to imgfetch all other relevant files so that it ends up in the same virtual fs, but not sure that will work eighter...

However there is one hack that works, using wimboot,
What you do is that you imgfetch all files that you need to have available,
The bootable file that you want to boot needs to be named bootx64.efi localy which can be don with imgfetch -n bootx64.efi file://grubx64.efi
and finally you chain to wimboot and that should create a virtual VFAT fs (which can be read by grub), and then boots bootx64.efi which is your grub.

imgfetch is the same thing as initrd and -n is the shorthand option for --name which you can find in the documentation.

PS might be wrong about the name bootx64.efi, but wimboot will tell you if that's the case


RE: chain load with EFI and file:/ URL - sherpya - 2018-01-16 19:20

I had the same problem http://forum.ipxe.org/showthread.php?tid=10703, even if the file is correctly loaded in memory


RE: chain load with EFI and file:/ URL - NiKiZe - 2018-01-16 20:15

(2018-01-16 19:20)sherpya Wrote:  I had the same problem http://forum.ipxe.org/showthread.php?tid=10703, even if the file is correctly loaded in memory

sherpya your thread seems to be about booting wimboot from grub.
This thread is about issues with starting grub from iPXE when it is loaded via file:// (grub itself starts fine, but can't find the files it expects to)


RE: chain load with EFI and file:/ URL - sherpya - 2018-01-20 04:58

(2018-01-16 20:15)NiKiZe Wrote:  
(2018-01-16 19:20)sherpya Wrote:  I had the same problem http://forum.ipxe.org/showthread.php?tid=10703, even if the file is correctly loaded in memory

sherpya your thread seems to be about booting wimboot from grub.
This thread is about issues with starting grub from iPXE when it is loaded via file:// (grub itself starts fine, but can't find the files it expects to)

I chainload snponly.efi so it's more or less the same thing (file:// points to a filesystem), then when I try to load files using file:// protocol on the usb storage, files are correctly loaded, but ipxe gives no such device if I try a command that "executes" the image

By looking at the sources `last_opened_snpdev()` returns null


RE: chain load with EFI and file:/ URL - sherpya - 2019-05-01 12:36

try to add ifopen on top of the script, I've managed to make grub2 -> wimboot (chainload) work