Interactive PXE Boot Menu

I have been asked to modify our PXE server such that there will be only one entry in the pxelinux.cfg/default file, where the same kernel and initrd.img will be used regardless of what operating system is to be installed, and the user will type in the path to the kickstart file that will be used. I have attempted to complete this task by using a modular kickstart, and asking for user input in the %pre section, which failed miserably. I have also looked into the possibility of getting user input from the PXE boot menu. Is it somehow possible to refer back to the user input when using prompt 1....label? Can this information be referenced other than by using label? Is there a better way to accomplish this?

Unfortunately, installing extra packages or tools on our pxe server is not an option.

I think you can pass kernel options on the PXElinux commandline, like 'kernel option anotheroption'. These would be passed into the kernel commandline of whatever's loaded, and it can decide from there how to deal with it. An initrd would be best so you could embed scripts for it before anything is mounted or what have you.

Forgive me if my question seems silly, but are you referring to the append section (of pxelinux.cfg/defualt) as the place to pass kernel options? As in:

label centos6.0
kernel CentOS6.0/vmlinuz
append initrd=CentOS6.0/initrd.img ....... ks=....

I would like to use a variable to specify the kickstart file, so I could have something like:

ks=nfs:<IP-ADDRESS>/$PATH_TO_KICKSTART

As for initrd, I am not familiar with that. I will do some research. Thanks for the suggestion. Would an initrd allow me to add kernel options? PXE booting is obviously fairly new to me.

No, I mean the place where the user types. You can specify options there, and they do get passed to the kernel commandline.

I was under the impression that the PXE menu uses prompt to determine which label to go to to specify the said kernel options. How would I then prompt the user for the path to the kickstart file? If there is a way to refer back to what the user had typed (for instance, $1, as in a bash script) then I could simply leave out the menu options and intruct the user to type in the path to the kickstart file they wish to use. I am thinking, however, that this is not possible. Am I better off customizing an initrd.img file?

Yes, it uses the labels. It should also be able to take options after the label, like

labelname option anotheroption

which would go into the kernel commandline options.

These options would be available via /proc/cmdline once the kernel boots, for you to use how you please in the initrd.

So you'd be customizing an initrd either way, really.

Ok I see what you mean, but I still do not understand how I can prompt the user for a kickstart file path, store their input in a variable, and then reference said variable when I pass the ks= kernel commandline option. I understand how the PXE menu works, but the problem is that our menu file is growing rapidly as we add distros, and I have been asked specifically to get it down to one default entry. If there is a way to reference the user's input (other than by using a label) then this can be easily accomplished. I do not think this is possible to do at this point, however.

I don't think you can in pxelinux itself. That may take a really complicated bootloader like grub2. Probably better to alter your initrd.

If you do go that route, you might be interested to know you can have have more than one initrd.

append initrd=.../whatever.img initrd=list-of-kickstarts.img

Which could let you update the list of kickstart variables/paths/whatever without modifying your initrd or pxelinux.