PXE chainloader
Signature · 3 lines
-- Regards Vladimir 'φ-coder/phcoder' Serbinenko
=== modified file 'grub-core/Makefile.core.def'
Makefile.core.def +6 -0
@@ -1064,6 +1064,12 @@ }; module = { + name = pxechain; + i386_pc = loader/i386/pc/pxechainloader.c; + enable = i386_pc; +}; + +module = { name = multiboot2; cppflags = "-DGRUB_USE_MULTIBOOT2";
=== added file 'grub-core/loader/i386/pc/pxechainloader.c'
loader/i386/pc/pxechainloader.c +130 -0
130 lines not on this page · raw message
The output of two tests follow. It works, to an extent. Is PXE being left in a state where the next bootloader can call it's initialization routines again?
Test 1: Boot grub PXE, chainload grub PXE, chainload grub PXE again.
Result: Chainloaded grub PXEs load in rescue mode.
Pre-boot eXecution Environment (PXE) 2.43
(C) Copyright 1999 Intel Corporation
(C) Copyright 2000 Lanworks Technologies Co. a subsidiary of 3Com Corporation All rights reserved
CLIENT MAC ADDR: XX XX XX XX XX XX GUID: 00020003-0004-0005-0006-000700080009 CLIENT IP: 192.168.2.101 MASK: 255.255.255.0 DHCP IP: 192.168.1.1 GATEWAY IP: 192.168.2.1
Welcome to GRUB!
GNU GRUB version 1.98
Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists possible device or file completions.
grub> pxechainloader (pxe)/boot/grub/grub2pxe
grub> boot
Welcome to GRUB!
error: file not found.
Entering rescue mode...
grub rescue> insmod pxechain
grub rescue> pxechainloader (pxe)/boot/grub/grub2pxe grub rescue> boot
Welcome to GRUB!
error: file not found.
Entering rescue mode...
grub rescue>
Test 2: Boot grub PXE, chainload pxelinux (Debian Lenny net installer)
Result: Chainloaded pxelinux fails to initialize UDP stack.
Pre-boot eXecution Environment (PXE) 2.43
(C) Copyright 1999 Intel Corporation
(C) Copyright 2000 Lanworks Technologies Co. a subsidiary of 3Com Corporation All rights reserved
CLIENT MAC ADDR: XX XX XX XX XX XX GUID: 00020003-0004-0005-0006-000700080009 CLIENT IP: 192.168.2.101 MASK: 255.255.255.0 DHCP IP: 192.168.1.1 GATEWAY IP: 192.168.2.1
Welcome to GRUB!
GNU GRUB version 1.98
Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists possible device or file completions.
grub> pxechainloader (pxe)/boot/debian/lenny/i386/pxelinux.0 grub> boot
PXELINUX 3.71 Debian-2008-09-06 Copyright (C) 1994-2008 H. Peter Anvin Found PXENV+ structure
PXE API version is 0201
UNDI data segment at: 00096690 UNDI data segment size: 4801 UNDI code segment at: 0009AEA0 UNDI code segment size: 3160
PXE entry point found (we hope) at 9AEA:00FA Getting cached packet 01
Getting cached packet 02
Getting cached packet 03
My IP address seemes to be 45A84865 192.168.2.101 ip=192.168.2.101:192.168.1.1:192.168.2.1:255.255.255.0 Failed to initialize UDP stack
Boot failed: press a key to retry, or wait for reset...
Signature · 1 line
Omni Flux
Quoted 4 lines · Omni Flux
The output of two tests follow. It works, to an extent. Is PXE being left in a state where the next bootloader can call it's initialization routines again?
Attached patch may help. I noticed that last file may still remain opened.
Quoted 90 lines
Test 1: Boot grub PXE, chainload grub PXE, chainload grub PXE again.
Result: Chainloaded grub PXEs load in rescue mode.Pre-boot eXecution Environment (PXE) 2.43
(C) Copyright 1999 Intel Corporation
(C) Copyright 2000 Lanworks Technologies Co. a subsidiary of 3Com Corporation
All rights reservedCLIENT MAC ADDR: XX XX XX XX XX XX GUID:
00020003-0004-0005-0006-000700080009
CLIENT IP: 192.168.2.101 MASK: 255.255.255.0 DHCP IP: 192.168.1.1 GATEWAY IP: 192.168.2.1
Welcome to GRUB!GNU GRUB version 1.98
Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists possible device or file completions.
grub> pxechainloader (pxe)/boot/grub/grub2pxe
grub> boot
Welcome to GRUB!error: file not found.
Entering rescue mode...
grub rescue> insmod pxechain
grub rescue> pxechainloader (pxe)/boot/grub/grub2pxe grub rescue> boot
Welcome to GRUB!error: file not found.
Entering rescue mode...
grub rescue>Test 2: Boot grub PXE, chainload pxelinux (Debian Lenny net installer)
Result: Chainloaded pxelinux fails to initialize UDP stack.Pre-boot eXecution Environment (PXE) 2.43
(C) Copyright 1999 Intel Corporation
(C) Copyright 2000 Lanworks Technologies Co. a subsidiary of 3Com Corporation
All rights reservedCLIENT MAC ADDR: XX XX XX XX XX XX GUID:
00020003-0004-0005-0006-000700080009
CLIENT IP: 192.168.2.101 MASK: 255.255.255.0 DHCP IP: 192.168.1.1 GATEWAY IP: 192.168.2.1
Welcome to GRUB!GNU GRUB version 1.98
Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists possible device or file completions.
grub> pxechainloader (pxe)/boot/debian/lenny/i386/pxelinux.0 grub> boot
PXELINUX 3.71 Debian-2008-09-06 Copyright (C) 1994-2008 H. Peter Anvin Found PXENV+ structure
PXE API version is 0201UNDI data segment at: 00096690 UNDI data segment size: 4801 UNDI code segment at: 0009AEA0 UNDI code segment size: 3160PXE entry point found (we hope) at 9AEA:00FA Getting cached packet 01
Getting cached packet 02
Getting cached packet 03
My IP address seemes to be 45A84865 192.168.2.101 ip=192.168.2.101:192.168.1.1:192.168.2.1:255.255.255.0 Failed to initialize UDP stackBoot failed: press a key to retry, or wait for reset...
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
=== modified file 'grub-core/Makefile.core.def'
Makefile.core.def +6 -0
@@ -1064,6 +1064,12 @@ }; module = { + name = pxechain; + i386_pc = loader/i386/pc/pxechainloader.c; + enable = i386_pc; +}; + +module = { name = multiboot2; cppflags = "-DGRUB_USE_MULTIBOOT2";
=== modified file 'grub-core/fs/i386/pc/pxe.c'
fs/i386/pc/pxe.c +7 -2
@@ -522,12 +522,17 @@void grub_pxe_unload (void ) { +struct grub_pxenv_tftp_close c; +if (grub_pxe_pxenv) {grub_fs_unregister (&grub_pxefs_fs);grub_disk_dev_unregister (&grub_pxe_dev); - - grub_pxe_pxenv =0 ; +if (curr_file !=0 ) + { +grub_pxe_call (GRUB_PXENV_TFTP_CLOSE , &c, pxe_rm_entry); + curr_file =0 ; + } } }
=== added file 'grub-core/loader/i386/pc/pxechainloader.c'
loader/i386/pc/pxechainloader.c +132 -0
132 lines not on this page · raw message
Quoted 6 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 4 lines · Omni Flux
The output of two tests follow. It works, to an extent. Is PXE being left in a state where the next bootloader can call it's initialization routines again?
Attached patch may help. I noticed that last file may still remain opened.
With this fix grub PXE can chain load itself recursively and load pxelinux successfully.
Unfortunately pxelinux then tries to find its configuration file in the wrong location because it takes the path from the boot file in the DHCP packet saved by PXE, which it expects to be pointing to itself but is actually pointing to grub itself.
I am not sure this is something we can reasonably fix, but it can be worked around by putting the pxelinux.cfg configuration in the same location as grub PXE.
Unfortunately, this means we cannot just download arbitrary distro installers, drop them in the tftp directory and point grub to their bootloaders.
Ideally, but probably not reasonable and/or possible would be if we could mangle the DHCP packets before chainloading so we could change the boot loader string and even add custom vendor options (either of which would allow specifying a different pxelinux.cfg location per menu item.)
I do not have any other PXE images to try, so I do not know if this issue affects any boot loaders besides pxelinux.
Signature · 1 line
Omni Flux
Quoted 4 lines
Unfortunately pxelinux then tries to find its configuration file in the wrong location because it takes the path from the boot file in the DHCP packet saved by PXE, which it expects to be pointing to itself but is actually pointing to grub itself.
Mangling the DHCP packet is probably the most flexible way to fix this, though it's a lot more complex than the current patch. PXELINUX does exactly this kind of mangling, so we might just be able to steal that code.
Regarding chainloading PXELINUX, it is possible to specify its configuration file search path in some PXELINUX-specific DHCP options, so that is another workaround.
http://syslinux.zytor.com/wiki/index.php/PXELINUX#Can_I_send_information_to_PXELINUX_via_special_options_in_the_DHCP_response.3F
Cheers,
--Ian
Quoted 1 line
Attached patch may help. I noticed that last file may still remain opened.
This works fine for me when chainloading PXELINUX or grub2 itself. But it fails when chainloading the Solaris 10 U8 pxegrub. Specifically, we are doing PXE -> Grub 2 -> pxegrub. pxegrub generates some output as follows:
Server: <correct IP address>
Site Option 150: <garbage>
BootFile: <bytes 1641-2049 of Grub 2's grub.cfg file>
Pxegrub then attempts to use the garbage above as a TFTP filename, which of course doesn't work. Also, note that we do not use site option 150 in our DHCP environment.
Note that chainloading PXE -> Grub 2 -> PXELINUX -> pxegrub generates exactly the same problem above as chainloading PXE -> Grub 2 -> pxegrub, but chainloading PXE -> PXELINUX -> pxegrub (i.e., without Grub 2) works just fine.
Cheers,
--Ian