Categories
OS Deployment

Windows PE PXE Boot Architecture Auto-Detection Using gpxelinux.0 From SYSLINUX

Here’s how I finally got architecture auto-detection for Windows PE working – using two separate TFTP servers, though, so it’s far from ideal.

Start by cloning your tftpboot directory and configuration to a new TFTP server. Next, get a copy of syslinux-3.86 (while the syslinux website is apparently down, and has been for a few months, googling for syslinux-3.86.tar.bz2 should make it show up on a mirror somewhere). You’ll need a working gcc toolchain, and a relatively recent version of nasm. Unpack the syslinux source somewhere, copy /gpxe/gpxelinux.0 and put it in tftpboot; change your DHCP server’s Option 67 to gpxelinux.0 instead of pxelinux.0.

Replace any existing *.c32 files in tftpboot with the ones from the syslinux source: you’ll probably find them in /com32/ somewhere. While you’re at it, you’re going to need /com32/modules/ifcpu64.c32 for the magic to work.

Next, edit /gpxe/pxelinux.gpxe, changing:

Code

imgload pxelinux.0
boot pxelinux.0

…with:

Code

set net0.dhcp/next-server <new TFTP server's IP>
set net0.dhcp/filename boot/pxeboot.0
chain tftp://${next-server}/boot/pxeboot.0

…and run make. This’ll produce a new gpxelinux.0, with a slightly different embedded script: this one overrides the DHCP results, replacing the information Windows PE’s pxeboot.0 examines to determine where to download the BCD and bootmgr.exe from, in effect redirecting the PXE boot to a completely different TFTP server. Copy the new gpxelinux.0 to tftpboot/gpxelinux64.0 (or something to distinguish it from the normal gpxelinux.0).

And finally, edit tftpboot/pxelinux.cfg/default, adding three entries like so:

Code

label windows
menu label Install Windows...
kernel ifcpu64.c32
append windows64 -- windows32

label windows32
menu label Win32
menu hide
kernel boot/pxeboot.0

label windows64
menu label Win64
menu hide
kernel gpxelinux64.0

Here’s what this does:

Details

  • PXE client requests gpxelinux.0 from the TFTP server specified in Option 66 (next-server)
  • gpxelinux.0 runs its embedded script, which is identical to pxelinux.0‘s behaviour: get DHCP configuration for the NIC, then search the TFTP server for an appropriate configuration file. Assuming that you have a basic setup, you’ll end up with tftpboot/pxelinux.cfg/default, which has our recent changes in it.
  • when a user selects the “Install Windows…” menu entry, ifcpu64.c32 determines whether the CPU is 64-bit capable, and loads:
    • the windows32 entry if the CPU is NOT 64-bit capable (read the append line as “true — false”, where “true” is the menu entry to load if the CPU is 64-bit, and “false” is the entry to load if it’s not).
    • the windows64 entry if the CPU is 64-bit capable. The windows64 entry loads our custom tftpboot/gpxelinux64.0, which modifies the (cached) DHCP response, setting Option 66 to a different TFTP server and Option 67 to Windows PE’s pxeboot.0 bootloader.

Now you can remove the extra BCD entries for each architecture and set the {bootmgr}‘s timeout value to 0 in the BCD files on each TFTP server, and you won’t have an extra menu popping up in-between gpxelinux.0‘s menu and the Windows PE environment.