iPXE discussion forum
Chainloading grub2 pxe efi file - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: Chainloading grub2 pxe efi file (/showthread.php?tid=8234)



Chainloading grub2 pxe efi file - anary - 2016-11-23 05:35

There appears to be a bug where iPXE cannot chainload a GRUB2 EFI file. This is used with Clonezilla & DRBL installations, where the GRUB2 file is dynamically generated.

Steven Shiau of the DRBL & Clonezilla projects posted something recently in the DEV e-mail chain about this, but did not get a response: http://lists.ipxe.org/pipermail/ipxe-devel/2016-October/005214.html

I've included the error, as described by Steven here:

---------------------------------------

Is this issue mentioned in this thread fixed?
http://lists.ipxe.org/pipermail/ipxe-devel/2015-October/004454.html
It seems the issue still remains. Here is my way to reproduce the issue:
1. On dhcp server, the isc-dhcp-server config is like:
option arch code 93 = unsigned integer 16;
if option arch = 00:06 {
filename "bootia32.efi";
} else if option arch = 00:07 {
filename "bootx64.efi";
} else if option arch = 00:09 {
filename "bootx64.efi";
} else {
filename "pxelinux.0";
}

The bootx64.efi was created on Ubuntu 16.04 x86-64 with this command:
grub-mkimage -C xz -O x86_64-efi -o /tftpboot/nbi_img/bootx64.efi
--prefix='(tftp)/grub-efi.cfg/' -c /tmp/grub-efi.70hXmd/grub-header.cfg
normal tftp efinet chain echo net gzio xzio linux efi_gop efi_uga png
gfxterm gfxterm_background gfxterm_menu serial part_gpt part_msdos boot
multiboot progress search ext2 xfs reiserfs jfs hfsplus fat ntfs
configfile test sleep tr reboot halt
The contents of /tmp/grub-efi.70hXmd/grub-header.cfg:
*****************************************************.
set prefix=(tftp)/grub-efi.cfg
echo "Grub CPU and platform: $grub_cpu, $grub_platform"
echo 'Network status: '
net_ls_cards
net_ls_addr
net_ls_routes

tr --set pretty_mac x: x- $net_default_mac

echo "Loading config file $prefix/grub.cfg-01-$pretty_mac..."
configfile $prefix/grub.cfg-01-$pretty_mac

echo "Loading config file $prefix/grub.cfg-$net_default_ip..."
configfile $prefix/grub.cfg-$net_default_ip

echo "Loading config file: $prefix/grub.cfg"
configfile $prefix/grub.cfg

echo "Could not find config file $prefix/grub.cfg-$pretty_mac,
$prefix/grub.cfg-$net_default_ip or $prefix/grub.cfg!"
sleep 15

*****************************************************.

In the client I boot a live CD (Clonezilla live) on uEFI machine, with
iPXE in the grub2 config:
menuentry "iPXE"{
search --no-floppy --set=root -f /live/ipxe.efi
chainloader /live/ipxe.efi + 1
}

The ipxe.efi was compiled with the latest release from iPXE git repository:
https://git.ipxe.org/ipxe.git/commit/0be77e959e813773cac10f049cb62c83258f81ff

So when iPXE uEFI boots, it gets the IP address from the DHCP server,
downloads bootx64.efi, the output on the screen is attached as ipxeboot.png.
Later then it stops at:
Could not find config file (tftp)/grub.cfg-, (tftp)/grub.cfg- or
(tftp)/grub.cfg!
(See attached file grub-stop.png).
And after 15 secs, it enters grub shell (see attached grub-shell.png).

ATTACHMENTS:
http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20161022/43bec68d/attachment-0003.png
http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20161022/43bec68d/attachment-0004.png
http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20161022/43bec68d/attachment-0005.png


RE: Chainloading grub2 pxe efi file - NiKiZe - 2016-11-23 19:10

I think your issue could be solved by enabling the "EFI downgrade" option see the commit at http://git.ipxe.org/ipxe.git/commitdiff/a15c0d7

If that solves your issue you might want to contact the Grub people and try to get them to make a fix on their end.

But there is no need to use Grub since you can have both menu and loading of kernel directly from ipxe, grub does not give any benefit IMHO


RE: Chainloading grub2 pxe efi file - steven - 2016-11-27 04:41

(2016-11-23 19:10)NiKiZe Wrote:  But there is no need to use Grub since you can have both menu and loading of kernel directly from ipxe, grub does not give any benefit IMHO
Could you please shed more lights about this? Some examples or docs will be great. Thanks.

Steven


RE: Chainloading grub2 pxe efi file - NiKiZe - 2016-11-27 16:45

There is loots and loots of examples on how to use ipxe to load different things, but below is example for working in both legacy and efi mode and depnding on CPU bitness

In this case it is based on systemrescuecd

Code:
#!ipxe

# if kbmap is not already set, we set a default to avoid question on boot
isset ${kbmap} || set kbmap us

# generate a setting with 32 or 64 depending on what the cpu supports
cpuid --ext 29 && set bitn 64 || set bitn 32


# This is for 4.8.1-beta002.iso or later
kernel altker${bitn} initrd=initram.igz initrd=sysrcd.dat.cpio edd=off vga=791 scandelay=0 dodhcp setkmap=${kbmap} nomdadm nodmraid rootpass=l
initrd initram.igz

# ipxe does currently only support adding cpio headers on the fly to bzImage boots,
# but not efi, for now use preadded cpio header
# generate with: echo sysrcd.dat | cpio -H newc -o > sysrcd.dat.cpio
initrd sysrcd.dat.cpio

boot

If you put this in a separate "sysrcd.ipxe" file and then chain http://server/sysrcd.ipxe
it should boot (As long as you have all the other files available as well)

This is just an example, and it can be done easier and more advanced, it is also possible to have menues and other things, se http://ipxe.org/cmd/menu as a base for how menues can be implemented.


RE: Chainloading grub2 pxe efi file - anary - 2016-12-07 01:57

(2016-11-23 19:10)NiKiZe Wrote:  I think your issue could be solved by enabling the "EFI downgrade" option see the commit at http://git.ipxe.org/ipxe.git/commitdiff/a15c0d7

If that solves your issue you might want to contact the Grub people and try to get them to make a fix on their end.

Enabling EFI downgrade did not appear to have any effect. The same error message that steven is describing persists.

Any other options besides scrapping GRUB?


RE: Chainloading grub2 pxe efi file - magarvo - 2017-08-28 15:42

I've come across this problem when trying to chainload GRUB2 as a workaround to the booting of RHEL 7.3 install images.

Has anyone experienced this also?