PXE Boot - Boot Your Machine Over the Net

See http://syslinux.zytor.com/

At certain times of the year I might be attempting to install dozens of machines for our cluster. Inserting a CD is fine for one, not for twenty. Of more interest, though, is that I want a variety of things to boot. I want a Debian Stable ISO to boot. Most importantly, I want to boot Dell diagnostics.

This process usings something called PXE. It requires your machine's BIOS to make a request of a TFTP server for a bootable image (the equivalent of inserting a CD and booting). Most modern higher-end machines can do this - and particularly all Dell PowerEdge machines, which is what I support. I use a Debian distribution, so what follows is debianish. Whatever you have will almost certainly have something similar. You should also check out the SARA package of utilities at https://subtrac.sara.nl/oss/pxeconfig.

  • Install a tftp server. I chose atftpd and did the following:
      apt-get install atftpd
      # Set up atftpd  (do not use inetd, since it hardly ever gets used)
      touch /var/log/atftp.log     # Enable logging
      vi /etc/default/atftpd
        #  verbose=7 --trace will trace every packet
        OPTIONS="--daemon --verbose --tftpd-timeout 10 --retry-timeout 5 \
          --mcast-port 1758 --mcast-addr --mcast-ttl 10 \
          --maxthread 10 --verbose=5 --logfile=/var/log/atftp.log /tftpboot"
      update-inetd --disable tftp
      /etc/init.d/atftpd restart

  • Install syslinux and set up a TFTP boot server. DHCP can do this for you. Here's what I did:
      apt-get install syslinux
      mkdir -p /tftpboot/boot tftpboot/pxelinux.cfg
      chmod 777 /tftpboot
      # Copy files from syslinux distribution to /tftpboot
      cp -p /usr/lib/syslinux/pxelinux.0 /tftpboot
      cp -p /usr/lib/syslinux/menu.c32   /tftpboot
      cp -p /usr/lib/syslinux/memdisk    /tftpboot/boot

  • Configure dhcp so it allows a TFTP boot to happen. I won't provide the all DHCP details, but for this step all you need do is add some lines like this to your dhcp.conf file. Yes, the pxelinux.0 file you see below is the same one from the previous step.

    allow booting;
    allow bootp;
    filename "/tftpboot/pxelinux.0";

  • Make default menus for pxelinux. Note that executables to be run (kernel keyword) cannot have special chars. Keep these names v-e-r-y simple. The menu.c32 is a small program to generate a menu so you can select what to do. Here's what I have right now:
    cat /tftpboot/pxelinux.cfg/default
    DEFAULT menu.c32
    PROMPT 0
    TIMEOUT 100
    #   First one is default unless 'DEFAULT name' specified
    LABEL delldiags
      MENU LABEL Dell Diagnostics (EW5091A1 DOS mode)
      kernel boot/memdisk
      append initrd=boot/delldiag.img
    LABEL installi386
      MENU LABEL Install Debian Etch I386 over Network
      kernel boot/debian/i386/linux
      append vga=normal initrd=boot/debian/i386/initrd.gz -- 

  • Get memtest from http://www.memtest.org. Download the file labelled Download - Pre-Compiled package for Floppy (DOS - Win) and then do:
      cd /tmp    # or some directory for temporary files
      unzip memtest86+-1.70.floppy.zip 
      cp -p floppy/memtestp.bin  /tftpboot/boot/memtestp
      rm -rf /tmp/floppy

  • Get the Debian network installer (or your favorite). The process for this is described in: http://www.debian.org/releases/stable/i386/ch04s06.html.en, http://www.debian.org/releases/stable/i386/ch04s02.html.en#where-files, and http://ftp.debian.org/debian/dists/etch/main/installer-i386/current//images/netboot/. Fetch netboot.tar.gz and extract it in a safe place:
      mkdir -p /tftpboot/boot/debian/i386
      cd where-netboot-extracted
      cp -p debian-installer/i386/linux     /tftpboot/boot/debian/i386
      cp -p debian-installer/i386/initrd.gz /tftpboot/boot/debian/i386
      # Edit /tftpboot/pxelinux.cfg/default and add an entry from pxelinux.cfg/default as necessary.
  • Get Dell diagnostics from http://support.dell.com/.
    • Select Drivers and Downloads
    • Select product by model, service tag or whatever. PowerEdge works fine, others apparently do not
    • At page Drivers and Downloads Search Criteria, select Operating System as MS-DOS
    • Select Diagnostics
    • Download the 2MB image
    • Extract on a Windows system. What! Of course, remember it's called a MONOPOLY. Fine, visit one of your poor friends who are stuck on a Windows machine. Copy the 2MB file to the Windows machine, then execute it. This program copies files to a directory and invokes an application which will create Floppy boot images, USB boot image or a 'Bootable Image'
    • Select Bootable Image and save the *.img file
    • Copy the *.img file back to your Linux and do cp -p diags.img /tftpboot/boot/delldiag.img
    • Edit /tftpboot/pxelinux.cfg/default and add an entry for Dell diagnostics as necessary

You should now be able to boot a machine on your DHCP network and choose to boot from the network. On Dell machines this is F12 labelled 'PXE Boot'. If all went well, you should get a menu showing you several things defined in /tftpboot/pxelinux.cfg/default and allow you to boot from these.

I must tell you, it's a real joy to PXE boot and run diagnostics so easily. Good job, Dell.