Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Embedded iPXE menu to choose which network adapter to boot from (autodetects up to 10 adapters)

Go into your git checkout folder of ipxe.

Save the below file as nic-menu.ipxe.

Build iPXE like this:

cd src && make EMBED=../nic-menu.ipxe && cd ..

Requirements: current iPXE as of 2013-08-01 (for proper behavior of autoboot with a network device specified, netX feature, PCI vendor/device ID display and inc command)

set timeout 1000
menu Network boot options for ${uuid}
item --key a default Try to boot (a)ll network adapters in turn
item --gap -- --- Detected network adapters ---
set i:int8 0
ifopen net${i} && item --key ${i} net${i} net(${i}): ${netX/mac} - ${netX/bustype} ${netX/busloc:busdevfn} ${pci/${netX/busloc}.0.2}:${pci/${netX/busloc}.2.2} ${netX/chip} ; ifclose
inc i
iseq ${i} 10 || goto loop
item --gap -- --- Alternatives ---
item --key c config Open (c)onfiguration
item --key r reboot (R)eboot computer
item --key s shell Drop to iPXE (s)hell
item --key x exit E(x)it and continue BIOS boot order
choose --timeout ${timeout} selected && goto select || goto default
goto menu
isset ${${selected}/mac} && goto nic || goto label
autoboot ${selected} && goto exit ||
echo Booting '${selected}' failed, exiting iPXE...
goto exit
goto ${selected} ||
echo The label '${selected}' could not be found, returning to menu...
sleep 2
goto restart
autoboot && goto exit ||
echo Booting failed, exiting iPXE...
goto exit
goto restart
goto restart
set timeout 0
goto menu
echo Continuing BIOS boot order...
sleep 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.