Combining Windows Deployment Services & PXELinux for the ultimate network boot

In a previous article, Installing Linux via PXE using Windows Deployment Services (WDS), I talked about using PXELinux to enable deployment of WDS images, Linux distros and a multitude of tools. It got a bit heavy when trying to make this all work but the system is now up & running and we have already benefitted from it on many occasions. So here is my guide for Microsoft admins wanting to enhance their existing Windows Deployment Services server.

Step One – Install WDS

This should be obvious and if you are reading this I imagine you’ve done it already. Ours is running on a Windows Server 2003 box but it should work fine with the latest, more secure, stuff.

  • We will be adding bits to the folders within the \\WDS\REMINST share

Step Two – Install PXELinux

PXELinux is part of the SysLinux package

  • Download SysLinux from here
  • There’s quite a bit in SysLinux but you only need to extract the following files
    • ZIP\core\pxelinux.0
    • ZIP\com32\menu\vesamenu.c32
    • ZIP\com32\modules\chain.c32
  • Copy the files into \\WDS\REMINST\Boot\x86
  • Rename pxelinux.0 to pxelinux.com
  • You also need to make copies of two original WDS files in this folder
    • Copy pxeboot.n12 and rename it to pxeboot.0
    • Copy abortpxe.com and rename it to abortpxe.0
  • Create to new subfolders
    • \\WDS\REMINST\Boot\x86\Linux
    • \\WDS\REMINST\Boot\x86\pxelinux.cfg
  • The pxelinux.cfgfolder is where you store the files that make up the PXE boot (F12) menu.
    • All the files we will put in there are text files, even though they don’t use a .txt extension
  • First create a new text file called default.  This is the first menu that loads.
  • Paste the following text into it
    01 DEFAULT      vesamenu.c32
    02 PROMPT       0
    03
    04 MENU TITLE PXE Boot Menu (x86)
    05 MENU INCLUDE pxelinux.cfg/graphics.conf
    06 MENU AUTOBOOT Starting Local System in 8 seconds
    07
    08 # Option 1 - Exit PXE Linux & boot normally
    09 LABEL bootlocal
    10       menu label ^Boot Normally
    11       menu default
    12       localboot 0
    13       timeout 80
    14       TOTALTIMEOUT 9000
    15 # Option 2 - Run WDS
    16 LABEL wds
    17      MENU LABEL ^Windows Deployment Services
    18      KERNEL pxeboot.0
    19 # Option 3 - Exit PXE Linux
    20 LABEL Abort
    21     MENU LABEL E^xit
    22     KERNEL abortpxe.0
  • Now create a text file called graphics.conf
    • This file controls how the menu is displayed. It’s very versatile so have a play around until it looks as basic or as flashy as you like
  • Paste the following text into it
    01 MENU MARGIN 10
    02 MENU ROWS 16
    03 MENU TABMSGROW 21
    04 MENU TIMEOUTROW 26
    05 MENU COLOR BORDER 30;44     #00000000 #00000000 none
    06 MENU COLOR SCROLLBAR 30;44      #00000000 #00000000 none
    07 MENU COLOR TITLE 0      #00269B #00000000 none
    08 MENU COLOR SEL   30;47      #40000000 #20ffffff
    09 MENU BACKGROUND background.jpg
    10 NOESCAPE 0
    11 ALLOWOPTIONS 0
  • If you want to use a custom background, place it in the \\WDS\REMINST\Boot\x86folder.
    • The image should be a 640×480 jpeg file.
    • Make sure it has the same name as specified in the MENU BACKGROUND line in graphics.conf
  • Now we need to change the default boot program in WDS
    • Open the Windows Deployment Services Console
    • Right Click on your Server and select Properties
    • From the Boot tab change the default boot program for x86 architecture to \Boot\x86\pxelinux.com
    • In Server 2008 R2 you have to use the wdsutil  command line to set the the default boot program with these commands
1 wdsutil /set-server /bootprogram:boot\x86\pxelinux.com /architecture:x86
2 wdsutil /set-server /N12bootprogram:boot\x86\pxelinux.com /architecture:x86

Step Three – Test it out

Before you go any further, do a test PXE boot to check everything is OK.

I use a Hyper-V VM to make this testing process quicker. Just make sure it’s set to boot to a legacy network adapter in the settings

wds-pxe-menu

If it doesn’t load make sure you have the following files and folders in the right place within the \\WDS\REMINST share

  • \Boot\x86\pxelinux.com
  • \Boot\x86\vesamenu.c32
  • \Boot\x86\chain.c32
  • \Boot\x86\pxeboot.0
  • \Boot\x86\abortpxe.0
  • \Boot\x86\background.jpg
  • \Boot\x86\Linux\
  • \Boot\x86\pxelinux.cfg\
  • \Boot\x86\pxelinux.cfg\default
  • \Boot\x86\pxelinux.cfg\graphics.conf

Step Four– Add new boot options

If you can boot into the new menu and still load WDS then we are ready to add our Linux distros and other tools. If not, go back to step one and check everything.

This stage is relatively easy. It is just a case of putting the relevant netboot files for your preferred distribution in to the \Boot\x86\Linux folder and then adding a menu option for them. You can find more info on where to get these from on the official WDSLinux wiki. I’ll show you a more generic way of doing things using Debian as an example

  • Create a new subfolder
    • \Boot\x86\Linux\Debian\
  • Download the netboot files (initrd.gz and linux) from a Debian mirror
  • Copy them into the Debian subfolder
  • Create a menu entry for them in \Boot\x86\pxelinux.cfg\default
    1 LABEL debian6Netinstall
    2     menu label ^Debian 6-0 Net-install
    3     # Load the correct kernel
    4     kernel /Linux/Debian/Linux
    5     # Boot options
    6     append priority=low vga=normal initrd=/Linux/Debian/initrd.gz

That’s all there is to it. As long as you download the correct files and boot the correct boot options on the append line of the menu, you should be OK.

What if I need 64-bit options

This is easy too just replicate everything we did in \Boot\x86 into \Boot\x64. Don’t forget to change the WDS Server boot program for the x64 architecture (as shown in step 2) to \Boot\x64\pxelinux.com

Taking it further

Hopefully you are reading this because you have numerous ideas of what you could boot to. To help you along I’ve included my current default menu as well as adding sub-menus for Linux and Tools. Most of them were fairly straightforward as they had special PXE version with instructions on their website, e.g. GParted & Clonezilla

default

01 DEFAULT      vesamenu.c32
02 PROMPT       0
03
04 MENU TITLE PXE Boot Menu (x86)
05 MENU INCLUDE pxelinux.cfg/graphics.conf
06 MENU AUTOBOOT Starting Local System in 8 seconds
07
08 # Option 1 - Exit PXE Linux & boot normally
09 LABEL bootlocal
10       menu label ^Boot Normally
11       menu default
12       localboot 0
13       timeout 80
14       TOTALTIMEOUT 9000
15 # Option 2 - Run WDS
16 LABEL wds
17      MENU LABEL ^Windows Deployment Services
18      KERNEL pxeboot.0
19 # Go to Linux sub-menu
20 LABEL linux
21     MENU LABEL ^Linux Distros
22     KERNEL vesamenu.c32
23     APPEND pxelinux.cfg/graphics.conf pxelinux.cfg/linux.menu
24 # Go to Tools sub-menu
25 LABEL tools
26     MENU LABEL ^Tools
27     KERNEL vesamenu.c32
28     APPEND pxelinux.cfg/graphics.conf pxelinux.cfg/tools.menu
29 # Exit PXE Linux
30 LABEL Abort
31     MENU LABEL E^xit
32     KERNEL abortpxe.0

linux.menu (save in same place default)

01 MENU TITLE Install a Linux Distro
02
03 LABEL debian6.0-amd64-Netinstall
04     menu label ^Debian 6-0 amd64-Net-install:
05     kernel /Linux/Debian-Net-Install-amd64/Linux
06     append priority=low vga=normal initrd=/Linux/Debian-Net-Install-amd64/initrd.gz
07
08 LABEL Centos5.0-Install
09     menu label ^Centos 5-0 32bit install:
10     kernel /Linux/Centos-5.0-32-bit/vmlinuz
11     APPEND ks initrd=Linux/Centos-5.0-32-bit/initrd.img ramdisk_size=100000
12
13 LABEL Debian-5.08-Installer
14     menu label ^Install 5.08 (Lenny)
15     kernel /Linux/debian-installer/i386/linux
16     append vga=normal debian-installer/allow_unauthenticated=true  initrd=/Linux/debian-installer/i386/initrd.gz
17
18 LABEL Main Menu
19       MENU LABEL ^Back to Main Menu
20       KERNEL vesamenu.c32
21       APPEND pxelinux.cfg/default

tools.menu (save in same place default)

01 MENU TITLE Tools
02
03 LABEL memtest
04     menu label ^Memory Test: Memtest86+ v4.20
05     kernel \Linux\memtest\memtestp
06 LABEL Clonezilla Live
07     MENU LABEL ^Clonezilla Live
08     kernel \Linux\Clonezilla\vmlinuz
09     append initrd=\Linux\Clonezilla\initrd.img boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=788 nosplash fetch=http://192.0.0.24:81/RemoteInstall/Boot/x86/Linux/Clonezilla/filesystem.squashfs
10 LABEL gparted
11     MENU LABEL ^GParted Live
12     kernel \Linux\gparted\vmlinuz
13     append initrd=\Linux\gparted\initrd.img boot=live config  noswap noprompt  nosplash  fetch=http://192.0.0.24:81/RemoteInstall/Boot/x86/Linux/GParted/filesystem.squashfs
14     TEXT HELP
15         GParted live version: 0.8.1-3. Live version maintainer: Steven Shiau
16         Disclaimer: GParted live comes with ABSOLUTELY NO WARRANTY
17         ENDTEXT
18 LABEL Main Menu
19     MENU LABEL ^Back to Main Menu
20     KERNEL vesamenu.c32
21     APPEND pxelinux.cfg/default

Conclusion

This is a really useful tool to have in our SysAdmin arsenal. I encourage you to give it a go. Let me know if your successful, or if you are having any problems getting it working, in the comments section. I’d also love to hear of any other tools you’ve added to the PXE menu.