iPXE discussion forum

Full Version: creating menus
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I'm trying to set up a bootmenu for my computers for days now. A user booting from the net should be able to select from a number of options, including booting from an iSCSI target, his local harddisk (if any), loading a number of installers (Linux, FreeBSD) or loading several rescue / backup / diagnosis tools.

Unfortunately I'm failing in creating any option to get sanboot working.

So just a general question:
What is the recommended way to create bootmenus these days?
I've come to ipxe the long way, first trying out pxelinux, then gpxe. Unfortunately the first one isn't documented at all (website's down for ages), the second doesn't boot correctly (trying to use some cached values, then bails out / hangs).

I'm able to boot from any iSCSI target I want to, either via the ipxe built-in shell or via any ipxe script. But I'm not able to create a nice menu for it.

First I tried to use the menu.c32 supplied with pxelinux. This lets me create a menu, but neither chain back to ipxe correctly (loads undionly but then reloads the menu, aka infinite loop and I can't find a way to pass the correct ipxe script as a parameter to it), nor use sanboot.c32 (complains about missing API and bails out too). Chaining into gpxe or gpxelinux didn't work either: Either it hangs trying to load its configfile (pxelinux.cfg/default) or, if this worked, it fails accessing the network complainging about timeouts.
Again: iPXE works like a charm, but without menus and menu.c32 seems to work as long as I "only" load an image as kernel (i.e. live system or CD Image using memdisk).

Currently dhcp (ISC DHCPD 3) is configured to hand out undionly.kpxe first hand, and, after ipxe does its own dhcp request, hand out bootmenu.cfg as filename. This gets loaded correctly. From there I'm able to boot from an iSCSI target or load any Image or boot into a diskless configured FreeBSD and so on. But no menu.

So again: How can one set up a nice menu including booting from any iSCSI target, preferrably without setting up a webserver and writing custom php scripts, but using a static configuration like in the old days with pxelinux and menu.c32. Setting up a webserver would be heavy overkill for me Wink

with kind regards,
I've actually been thinking about the same thing, as I prefer to use iPXE directly instead of having to chain off to pxelinux for menuing.

The most obvious way is to use the echo command from http://ipxe.org/cmd to display some text on the screen and then use the "read" command to store some text input in a variable. You could then use the scripting support (goto command) to choose other parts of the same script (or chain off to other special scripts for each purpose).

Incomplete (not tested) code below:

dhcp || goto retry
echo 1. iSCSI boot Windows 7
echo 2. iSCSI boot Ubuntu
echo 3. SystemRescueCD
echo 4. Ubuntu LTSP
echo 5. MythTV
read choice
goto menu_${choice} || exit
chain sanboot_win7.ipxe
goto menu
chain sanboot_ubuntu.ipxe
goto menu
chain sysrcd.ipxe
goto menu

If you get something working I'd be very much interested to hear back about it. I've been thinking about doing something like this myself, but never really gotten it off the ground. Something always seems to wisk me away somewhere else.
I had tried this also, but stalled when trying to create some menu logics Wink
As I prefer the layout of menu.c32 instead of having the users to type something in anyway, for now I stopped chaining from undionly to menu.c32 and than back to undionly. Instead I'm loading gpxelinux.0 directly wich jumps into menu.c32.

From there I'm able to boot ipxe.lkrn wich accepts an ipxe script as parameter like this (menu.c32 style config)
label sanboot
menu label Boot Win7 from iSCSI
kernel ipxe.lkrn
initrd ipxescripts/sanboot.ipxe

Now I have a directory called ipxescripts. Here I collect any "boot targets" I cannot call directly from menu.c32, as the sanboot I mentioned above. sanboot.ipxe for example looks like this:
ifopen net0
dhcp net0
set keep-san 1
sanboot iscsi:

This works like a charm. Now I have to find out why an old asrock board refuses to boot, but this is another (pxelinux related) problem.

Hope this helps you a bit
The only negative thing about that approach is that you require iPXE native drivers for all the menu entries that use ipxe.lkrn, as I believe the iPXE when loaded as .lkrn can't use UNDI (correct me if I'm wrong).

If all my hardware had (good) native iPXE support I'd go with that solution, but I'm forced to figure out something that can actually work with UNDI, as I have some fishy hardware (read: laptops).
To be honest, I have to admit I tried this only with two NICs: for testing I use virtualbox, the emulated NIC is some intel, for testing with real hardware I'm using a NIC called "intel gt gigabit desktop adapter". So both are Intel and both are working.

I also tried an old onboard NIC, something called Uli (Onboard NIC of an Asrock 939Dual-SATA2 Board). But I can't say anything about it: It doesn't load anything at all. pxelinux.0 stalls already when trying to load the configfile. This is the one I mantioned above. I decided to install another intel NIC, as far as I found out, there is a bug in (g)pxelinux.0 wich prevents some NICs from booting correctly, something about IRQs and other in-deep hardware related problems I can't solve.

regarding your undi issue: As far as I understand: If undionly loads, so should the lkrn module. You can also try to load the kpxe or the kkpxe module and chain from there into menu.c32. This should leave you with a working undi stack, shouldn't it? Anyway: Can I do something to find out if the lkrn uses undi or some native driver to help you?

To my knowledge, any .lkrn compile target will never use UNDI, even if support for it is compiled in. It will always use a native driver.

mcb30: Is this a bug or a limitation?

As to your asrock problem, you might make it work with typical chainloading. What is the PCI id of the network card on that card, and what does it identify as in Linux?
(2011-12-21 08:20)robinsmidsrod Wrote: [ -> ]To my knowledge, any .lkrn compile target will never use UNDI, even if support for it is compiled in. It will always use a native driver.

mcb30: Is this a bug or a limitation?

As to your asrock problem, you might make it work with typical chainloading. What is the PCI id of the network card on that card, and what does it identify as in Linux?

I didn't compile it my self. I took the .lkrn from the .iso wich is provided on ipxe.org. I don't have any computers with Linux installed and ipxe doesn't compile on FreeBSD. I'm able to boot via a livecd, but this isn't quite the environment to compile anything. Currently I don't have a computer available to install Linux, as I'm in the process of transforming my machines into diskless clients.

I tried the asrock as follows:
  • ipxe: boots, can load any .ipxe script and execute ist as long as I don't try to chain into (g)pxelinux.0 or gpxe.
  • (g)pxelinux.0 et al: loads the pxe module but stalls / hangs when loading its configfile (i.e. /pxelinux.xfg/default).
  • gpxe: doesn't even comes this far: hangs when trying to get a dhcp address, aparently isn't able to access the NIC correctly

According to lspci -v -nn -Q it identifies as follows:
00:11.0 Ethernet controller [0200]: ALi Corporation ULi 1689,1573 integrated ethernet. [10b9:5263] (rev 40)
        Subsystem: ASRock Incorporation Device [1849:5263]
        Flags: bus master, medium devsel, latency 128, IRQ 17
        I/O ports at e400 [size=256]
        Memory at febfec00 (32-bit, non-prefetchable) [size=256]
        Capabilities: [50] Power Management version 2
        Kernel driver in use: uli526x
        Kernel modules: uli526x

With kind regards,
There doesn't seem to be any uli526x driver in the iPXE tree, so I'm guessing that card is not supported. That means UNDI is your only option to drive it. If you're having problems with ipxe you might want to try and upgrade your vender PXE ROM. They might've patched some issues that could work in your favor.
In fact it says something about intel undi initializing itself. And I've read some posts on several mailinglists about pxelinux and the drived gpxe having problems with some onboard nics. Something about IRQs as far as I remember.
However, it works with ipxe and I'm planning to upgrade the computer with an intel gigabit card anyway. So I don't see a reason to mess around with bios updates and similar things. If anyone needs more information about this or the card I'd happy to help. But, as said above: It doesn't have any problems with ipxe.

If anyone is reading this entry, I'd just like to tell you all that since a couple of days ago, iPXE has native text mode menu support, via the new menu, item and choose commands. More information about it can be found here: http://ipxe.org/cmd/menu

If you need a complete example (my own menu used at home) you can find one here: https://gist.github.com/2234639
Reference URL's