Multi-level, Colorful and "Jazzy" PXE Boot Menus Made Easy
Novell Cool Solutions: AppNote
By Bryan Keadle
Digg This -
Posted: 7 Sep 2006
In a previous article, I gave a recipe for getting PXE working in your NetWare environment so that you can boot from a number of disk images such as support disks, installation disks, etc.
The default PXE menu isn't very "pretty"—basic grey on black.
Other than actually getting this menu from a network boot, there's nothing "cOOl" about this menu! How 'bout turning that, into this?!:
If you're one of those that like to "jazz up" your menus, and attempted to do so, you likely found that it takes quite a bit of time and effort, trial and error, and lots of internet searching to get the boot menu to look the way you want it. And, if you were testing your menus against your live PXE server, it can be a very slow, and potentially disruptive process. Also, many of the instructions assume you're doing the task on a Linux workstation. Perhaps you're still more comfortable working in Windows and would like to develop and make your mods using a Windows workstation. It was just too slow and complex to get to where you wanted to be, so you probably just gave up and settled for the default menu scheme. ...*BORING*...
If this describes you, read on...
Being bent on making the PXE boot menu "pretty", and easy to modify, I came up with a "PXE development environment" that lets me easily, and *QUICKLY* develop the PXE boot menu. Contained in the downloadable package with this article are a couple tools to make building your PXE menu an easy few steps:
- make modifications to the configuration file(s) for the menu items
(included ASCII utility for easily inserting ASCII control characters)
- modify your .BMP/.GIF image background image with your preferred graphic editor
(even as basic as Paintbrush/MSPaint!)
- run the provided conversion utility that converts your .BMP/.GIF image to the required .LSS format
(Convert2LSS.cmd, IrfanView and PPMtoLSS.exe)
- copy your configuration file and background image to the virtual floppy and save it
(Bootable SYSLINUX floppy - PXEDev.img and Virtual Floppy utility - VFD Win)
- boot your virtual machine from the virtual floppy and see how it looks.
(pre-configured virtual machine for testing included!)
It's that quick and easy. By booting a virtual machine to a virtual floppy, the reboots required for viewing your screens take only a couple seconds, and you don't risk effecting your production PXE server while testing.
Once I have a menu the way I want it, I simply make some minor changes to the menu configuration file(s) and copy the splash image(s) to my PXE server, and I now have an impressive, multi-level, colorful PXE Boot menu!
This "development environment" has saved me tons of time in trying to get just the right look and menuing functionality. This PXE Boot menu even has multiple menu screens accessible by pressing any of the F1-F9 function keys for a nice, multi-page boot menu. Here's how I did it...and how you can too...it's easy!
First, some brief technical details:
The PXE boot loader (PXELINUX) is a component of SYSLINUX but is specifically designed for network booting. To develop for PXELINUX, we can instead configure SYSLINUX (so that we can use a SYSLINUX-configured floppy for testing) the way we want the PXELINUX to appear, then when we have what we want, we make some minor configuration changes to the configuration text files we've been working with to make it "PXELINUX compatable", and then copy it to our PXE server to put it into production. Unfortunately, it appears that this PXELINUX boot loader does not support the gfxboot extension that gives you the rich, high resolution graphic support that you see when you boot from the Installation CD. So we won't be able to have our PXE boot menu *that* pretty, but at least SYSLINUX does give us 16-color, 640x480 graphic support to make it prettier than white-on-black text.
By using a virtual floppy in a virtual machine, the boot/reboot process is very fast. This is important, because you'll be doing alot of rebooting to see the results of your configuration changes.
So, let's first get you set up with this development environment:
Download the PXEDev.zip file, and extract it to a directory from which you will do your development work (eg: C:\PXEDev)
- Enable the Virtual Floppy utility (this is an *awesome*, very handy utility provided with permission by Ken Kato.)
- Browse to the VirtualFloppy subdirectory, and double-click on the VFDWin.exe
- Click on the Driver tab, and select Install, and then Start
- Click on the Drive0 tab, select the Open button, and browse to the VM subdirectory (eg: C:\PXEDev\VM) and select the file syslinux.flp and press Open
you now have a virtual B: floppy drive containing the syslinux files I've provided you. This same virtual floppy will be used by the VM to boot from.
- Browse to the VirtualFloppy subdirectory, and double-click on the VFDWin.exe
- Open the virtual machine (VMWare workstation or VMWare Player), browse to the VM subdirectory, and select the PXEDev.vmx file
(If you do not have VMWare workstation, you can download the *free* VMWare Player from here to run this virtual machine)
To see what you're starting with, simply Start the VM by pressing the Play/Start icon. You will see this VM boot from the virtual floppy image, and you'll get this first screen:
From this menu, you already have a number of preconfigured menu screens for you to start with. The configuration I've provided you give you screens for F1 - F9, and are as follows:
F1: Help menu:
F2: Main PXE Boot menu (as above):
F3: Support menu:
(This shows examples of providing a number of floppy images to boot from)
F4: Installs menu:
(This shows examples of SUSE OS installation options from an NFS Installation server.)
F5-F8: Additional "blank" menus
F9: a "colors" menu to help you work through your graphic image color index
So, now you have your development environment for easily modifying and testing of your PXE boot menus. I'll now go into detail for each of the 5 steps I listed above about how to make configuration changes:
At the root of the floppy is syslinux.cfg. This file correlates to the pxelinux.cfg/default file on your PXE server. You'll find a copy of my PXELINUX default file in your C:\PXEDev folder as default.example.txt for your reference. Here are the differences between SYSLINUX.CFG and PXE's DEFAULT configuration file:
The timeout 0 in SYSLINUX.CFG prevents the virtual machine from booting to the default option. You want to be able to toggle through your boot screens without a time limit. You'll see I have the F2.txt being the main boot menu (the menu you boot to). This is so the standard F1 "Help" key can serve as the "Help Menu" of your PXE Boot menu.
1) MENU CONFIGURATION FILES (F#.txt)
I have named each menu configuration file to match the F key it's associated to for convenience. The contents and syntax of this file is well documented in this documentation about SYSLINUX (SYSLINUX.TXT). These files are easily editable in any text editor like NOTEPAD. Though you already have F1.txt - F9.txt files, I've also include F#.txt as a blank template to work with. This file contains information about which graphic file to load and the text to display on the screen. However, the tricky part to configuring this file is the control characters required for specifying the colors and the graphic image. Though the SYSLINUX documentation (SYSLINUX.TXT) provides the information about these control characters, it's not at all apparent on *HOW* to use these control characters within the file. So, let me explain these control characters by spelling them out in text. Taking the main menu file, F2.txt, here's what it's doing. In bold are the escape codes as specified in the SYSLINUX documentation. The escape codes are then explained below the screen shot. The resulting screen it produces is shown below it:
<CAN>F2.lss - load the graphic file, F2.lss
<FF> - clear the screen
<LF> - Line feed - so that the text that follows is your first-line menus
^6 - change color of the following text to YELLOW
^7 - change color of the following text to WHITE
^b - change color fo the following text to CYAN
^f - change color of the following txt to GREY
Note the white space/blank lines down to the last line, Enter the boot option and press <return>. It's important to include this blank space if you want your boot: prompt to be on the last line of the screen. In your text editor, this last line is line 30 which will have it appear just one line above the boot: prompt.
As you play around with these control codes to get the right mix of colors and functions provided to you by SYSLINUX, you might not know how to enter these escape sequences in your text editor. To make inserting these control codes easy, I have included my utility called, asciichart.exe (in your C:\PXEDev folder). Simply run this executable:
From here, you can click on the ASCII code referenced in the SYSLINUX.TXT (for example, SI), click on the big button to put that escape code in your clipboard, then go to your text editor and paste it into the configuration file.
2) CREATING THE BACKGROUND IMAGE
With any graphics editor, even as simple as Paint Brush, create a 16-color, 640x470 (not 480!) to be your background image. The 470 height leaves you with the last line on the screen to be the boot: prompt line. In your C:\PXEDev folder, I have provided you with the graphic I've used for this article in both a .BMP and GIF format (pxesplash.bmp/.gif) for editing. Additionally, I've provided this same background in a number of different colors in the .LSS format for your convenience. Don't get too elaborate with your colors...keep it simple. The conversion of this image to a 16 color GIF and ultimately to the .LSS format required by SYSLINUX can result in some unexpected results. This SPLASH IMAGE HOWTO article provides some helpful information in this regard. Save your image(s) to your PXEDev directory for the next step (eg: pxesplash.bmp).
3) CONVERTING IMAGE TO LSS FORMAT
This is the step where most people give up on this effort because getting your .BMP (or .GIF) image converted to the .LSS format that SYSLINUX uses is too complex and/or confusing. However, I've managed to get this automated to a single command, Convert2Lss.cmd. This script utilizes two free graphic utilities, IrfanView and PPMtoLSS. Irfanview is an excellent graphic utility allowing you to do all kinds of graphical functions (view, convert, optimize), and in this case, batch-convert images. I use Irfanview to convert the specified image(s) to a PPM format, and then PPMtoLSS to convert it to the LSS format. Both these utilities are being provided in this package with permission by each respective author. To get the full functionality of IrfanView, please visit Irfan's website and download the complete product. I'm using only the small i_view32.exe component for the conversion.
From a command prompt, with your C:\PXEDev as your working directory, run:
You can specify a single filename, or wildcard characters are also accepted. So, for example, if you've created a number of .BMPs for different background screens, simply run:
The result will be same-named LSS files with an .LSS extension. If you don't specify a filename, it will default to converting pxesplash.bmp.
In the conversion process, you may need to specify the background color to match the background of your image. Additionally, you may want to specify a contrasting foreground color so that the text SYSLINUX prints to screen is readable over your background image. To do this, you will need to manually specify the color within the Convert2LSS.CMD script. Find in the script this section:
::SET BACKGROUND/FOREGROUND COLORS
Specify the BACKGROUND (color index 0) and FOREGROUND (color index 7) colors by changing the values here. Possible values are shown in the section above,
There are other 2 other modifications you may want (or need) to change in this script:
1) I have set the default filename to be converted to pxesplash.bmp. So you could run Convert2LSS.CMD with no parameters, and it will look for pxesplash.bmp to convert. If you would like to change this default filename, simply change the following lines near the top of the file, right after the :BEGIN label:
2) Sometimes for an image you're working with to get the color conversion to look right, you need to "swap" colors in the color palette. I don't completely understand how this works, but through trial and error, I was able to specify the correct color index to get the result I was looking for. Find in the script, this section:
::DEFINING COLOR INDEX
:: DEFAULT COLOR PALETTE: COLORS=%DRKBLUE%^=1 %DRKGREEN%^=2 %DRKCYAN%^=3 %DRKRED%^=4 %DRKPURPLE%^=5 %BROWN%^=6 %DRKGREY%^=8 %BLUE%^=9 %GREEN%^=10 %CYAN%^=11 %RED%^=12 %PURPLE%^=13 %YELLOW%^=14 %WHITE%^=15
REM set COLORS=%LTGREY%^=1 %LTGREY%^=2 %DRKGREY%^=3 %DRKRED%^=4 %DRKPURPLE%^=5 %YELLOW%^=6 %LTGREY%^=8 %BLUE%^=9 %GREEN%^=10 %CYAN%^=11 %RED%^=12 %PURPLE%^=13 %BROWN%^=14 %DRKGREY%^=15
un-REM the set COLORS line, and change the color index as needed. Here you're specifying what color goes to what color index, 1-15. You'll notice index 0 and index 7 are missing from this list. That's because you are already specifying the BACKGROUND color (index 0) and the FOREGROUND color (index 7). When trying to determine the correct color index for your background image, you can use the F9 PXE Menu to see the color index of your image (you'll need to copy your background image (.LSS file) you're working with to F9.lss on the floppy). So if, for example, your image is displaying RED instead of BLUE, identify the index color on the F9 menu screen, edit the Convert2LSS.cmd and specify BLUE at the color index number identified, then re-convert your image. Also, you need to make sure there are no duplicated colors. So if you specify RED as your BACKGROUND color, you need to make sure the RED is *NOT* defined in the set COLORS= line.
This process, getting the right colors, was the most difficult and confusing step for me. This is why I've provided you with a number of .LSS files with different color backgrounds for you to work with.
Again, IrfanView is an excellent utility for manipulating this color index. you can identify the colors' index in the image, change the colors, and even identify the HTML color code for the selected color (used in the Convert2LSS.cmd) by running Irfanview, open the pxesplash.gif image, and go to Image / Palette / Edit Palette menu option.
IrfanView was a must-have utility to successfully create my background images.
For more PXE menu backgrounds and configurations, check out this page where others have contributed their creative efforts.
4) SAVING FILES TO THE VIRTUAL FLOPPY
So, you now have your edited configuration file (eg: F2.txt) and your converted image (eg: pxesplash.lss) in your C:\PXEDev working directory. Copy the F2.txt to your virtual floppy (B:), and copy pxesplash.lss to your floppy as F2.lss:
copy F2.txt B:\ /y
copy pxesplash.lss B:\F2.lss
You need to "commit" these changes to the virtual floppy. Click on the Save button in your VFD Control Panel, check to Overwrite an existing file, and click Save.
If the Overwrite an existing file option is greyed out, you probably still have your VM "on", and it's using that file. You need to power off the VM first, then Save your virtual floppy.
Occassionaly, you may get a prompt like this:
Simply press Try Again and it's usually successful.
5) BOOTING THE VM FROM THE VIRTUAL FLOPPY
So, finally, you get to see the results. Power on the virtual machine. It will boot from your virtual floppy, and the first screen will be the F2.txt / F2.lss configuration. Use this same process to test your other screens (F1-F8).
PLACING YOUR DEVELOPMENT FILES INTO PRODUCTION
Once you have all your menus configured the way you want, you want to take these files (on B:) and copy them to your PXE Server (in the pxelinux.cfg directory). However, remember that the files you've been working with have been for SYSLINUX. You need to make some minor edits to the configuration files you just copied to make them work for PXELINUX. In each of the F#.txt files, you need to change the reference to the F#.lss file to be found in the pxelinux.cfg subdirectory. So, for example, the first line in your F2.txt file needs to be changed from F2.lss to pxelinux.cfg/F2.lss. Do this for each of your F#.txt files you copied from B: Also, verify that your default PXELINUX configuration file has the correlated file references as noted in the previous table showing the differences between syslinux.cfg and pxelinux.cfg/default.
Now, using your same PXEDev virtual machine, power on the VM, but instead of booting from the virtual floppy this time, press F12 at the POST to boot from the network. You will now see your new, pretty PXE Boot menu(s) in your production environment!
Creating fancy PXE Menus need not be as difficult to develop as you may have concluded when you originally pursued doing so. Though there are a number of resources documenting configuration options, I was unable to find anything straight forward and concise enough to make this process more understandable and manageable. Hopefully this article takes some of the mystery out of the available configuration options, and the utilities and "development environment" provided will give you a jump start to creating your own PXE Menus, and speed up the process to save you time and effort.
SYSLINUX TID: http://www.xs4all.nl/~hreuver/syslinux.txt
SPLASH IMAGE HOWTO: http://www.sweb.cz/Frantisek.Rysanek/splash/isolinux-splash-HOWTO.html
GIF COLOR INDEX EXPLAINED: http://www.scantips.com/palettes.html
Virtual Floppy Drive: http://chitchat.at.infoseek.co.jp/vmware/vfd.html
Virtual Machine Player: http://www.vmware.com/download/player/
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com