Wednesday, January 29, 2014

Understanding The PXE Boot Process

At my job, like most places, the servers we use are located in rooms or buildings other than where we are located.  Its not always feasable to be "AT" the server to do an install.  In fact, in our new environment, it is definitely not something that could happen without wasting the time to get down to the data center.

As those who have worked with HP rack mounted machines, they have an iLO (integrated Lights Out) interface to allow you to get to the machine remotely.  Its pretty nice to have this ability, I have to say, but using it does take a bit of learning the interface (which means keeping a reference list of commands is truly handy).

When we start up a machine for the first time, the only thing that the machine knows about itself is its MAC address, so when we turn it on, it broadcasts for a DHCP address.  Our DNS server picks up the request, matches the MAC to an entry in its tables and throws the assigned IP at the machine.

I know this article is about the PXE boot process, but I wanted to at least back up a touch and start at the beginning of our process.   The reason I did this is because of the MAC address.  Its actually quite important in the PXE boot process.  PXE is actually an acronym that stands for Preboot Execution Environment.  While there are a number of ways to network boot, this article only covers this method (as this is what we are using).  The reason I am covering this is because when you are in an environment that uses PXE booting along with things like kickstart, cobbler and puppet to get machines up, running and installed (as we do), then understanding each part of the process is critical for troubleshooting any issues that arise. 

In order to do PXE booting, you need a NIC that is PXE capable.  The reason for this is that PXE makes the NIC act as a boot device.  When you turn on the machine (whether sitting at the machine or doing it remotely, you need to watch the boot process and at the appropriate time, select to network boot.  Depending on what type of machine your on, your options will probably different so I am not going to say what key sequence you need to hit.  Simply watch the screen for the prompts.  If you miss it, reboot and try again. 

When you select network boot, the machine (actually the NIC) sends out a request to the DHCP server.  The DHCP server responds, returning an IP address for the client (that should be pre-setup) and also the address of the TFTP server and the location of the boot files on the server and the boot image (called pxelinux.0).

The machine then contacts the TFTP server, retrieves the pxelinux.0 image and executes it.  The boot image searches in the pxelinux.cfg directory on the server for boot config files that match the machine that is trying to boot.  There is an order to which the search for that file is performed:

- The first thing searched for is a file named with the MAC address of the machine.  The filename uses a '-' in place of the ':' that usually makes up a MAC address.
- If the file with the MAC is not found, then the search takes the IP of the machine, converts it to uppercase hex, which produces a string of 8 alpha-numeric characters.  The search then uses that hex string and searches for a file with that name.  If it doesn't find it, it then removes one character from the end and searches for a file with that new name.  It does this consecutively, each time removing a character from the hex string. 

Here is what the search process would look like:


If it does not find any profiles, then the boot process will then present a menu with a list of profiles (for us at least).  It should never actually get to that point.  If it does, then you need to check:

- that you have the MAC address correct in the DNS server.
- if you are using cobbler, then check that all machine information in cobbler is correct.

 I hope this allows you to better understand the PXE boot process.   I find it extremely useful. 

No comments:

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.