PXE Booting

From Wiki
Jump to: navigation, search

Most network PXE booting HOWTOs are useless from what I've seen. They either involve using another device to boot (CD, floppy, HD, etc.), didn't tell me what was going on behind the scenes, used BOOTP, or simply wasn't what I wanted. So here's this one.

You want to follow this document to setup the base of PXE network booting, and then one of the following documents to setup a specific linux distro to boot, or make your own. =)

Contents

Introduction

PXE booting is one of the many ways you can boot a computer (or embedded device, or just about anything, possibly a toaster even) entirely from the network without any form of storage on the destination computer (RAM aside). It can be used for most anything. You can run a complete OS off the network using just the RAM, or you can mass-install/update an OS stored on the local hard disk. This HOWTO will get the core of PXE booting setup, and from there you can use one of the above links to setup a specific distro.

Needed Hardware

Your average home hardware router will 100% not work. Quite a few high-end home routers will not work. The PXE client has to receive an additional DHCP option that 99% of the routers you've seen do not support. I can't say I've ever touched a Cisco router, but chances are decent that it'll support PXE booting. Read the next section for a little more detail as to why. For a list of hardware that has what's needed to do PXE booting, see PXE Capable Hardware.

PXE Boot Process

1. PXE client boots up, starts up PXE boot ROM.

2. The PXE boot ROM sends a DHCP request.

3. The responding DHCP request (should) contain an additional DHCP option, the "filename" options. (This is why the average hardware router won't work. You can't specify the needed options.)

4. The PXE client attempts to download the file specified over TFTP. (If not specified, the client tries to connect to the computer that gave it the DHCP lease. If the "next-server" param is specified, it will instead attempt to download the file off of that server. )

5. If the PXE client downloads the file, it then executes this file and from there PXE is out of the picture. That's the entire PXE process.

6. If any of the above steps fail, the computer should continue on with the boot process.

Used Software

dhcpd - the ISC DHCP server

PXELINUX - PXELINUX is a PXE boot loader, most commonly used to boot linux kernels over PXE (also see my modified pxelinux.0)

tftp-hpa - tftp server, which is used to obtain the needed config files, kernel, and depending, the initrd.

memtest86 - memtest86 is a very simplistic "OS" that we'll use just to ensure that PXE booting itself is working correctly - Memtest86


Installing Software on the Image Server

I'll keep this brief, and do it later. You need to install dhcpd and tftp-hpa, and just have pxelinux and memtest86 resident somewhere on the disk for later.

Configuring Software

DHCP

DHCPd

The DHCP configuration on most other HOWTOs have been ranging anywhere from 20 lines with no documentation, to a single line with documentation. I'll try and say what's needed and document it well.

DHCPd is setup with the "dhcpd.conf" file, commonly residing in your /etc directory.

First, my example setup.

ddns-update-style interim;
subnet 192.168.0.0 netmask 255.255.255.0 {
        range 192.168.0.10 192.168.0.254;
        default-lease-time 3600;
        max-lease-time 4800;
        option routers 192.168.0.1;
        option domain-name-servers 192.168.0.1;
        option subnet-mask 255.255.255.0;
        option ntp-servers 192.168.0.1;
}

host kyle {
        hardware ethernet 00:0C:6E:64:D8:B4;
        fixed-address 192.168.0.254;
        option host-name "kyle";
        filename "pxelinux.0";
        next-server 192.168.0.1;
}

We have two main blocks here, the subnet block

subnet 192.168.0.0 netmask 255.255.255.0 {
        range 192.168.0.10 192.168.0.254;
        default-lease-time 3600;
        max-lease-time 4800;
        option routers 192.168.0.1;
        option domain-name-servers 192.168.0.1;
        option subnet-mask 255.255.255.0;
        option ntp-servers 192.168.0.1;
}

and the host block.

host kyle {
        hardware ethernet 00:0C:6E:64:D8:B4;
        fixed-address 192.168.0.254;
        option host-name "kyle";
        filename "pxelinux.0";
        next-server 192.168.0.1;
}

For now, we'll concentrate on the host block, namely two parameters it takes. The "filename" and the "next-server", as these two are PXE-specific. next-server specifies which server (IP address only) to contact (via tftp) in order to download the next stage of the boot phase. Note that if you do not specify the next-server, then it will default to the IP address of the DHCP server where it obtained its IP address from. However, some motherboards seem to send packets to 0.0.0.0 and you might get a "martian destination" error in system log if you don't specify "next-server". The filename paramater specifies which file to download off of the specified tftp server, and then executed.

Now, as you can see, only the computer with the MAC address 00:0C:6E:64:D8:B4 is instructed to download the pxelinux.0 file and execute it. If you were to deploy this over an entire subnet, it'd be a tedious task to create host blocks for every computer. Likewise, the following is perfectly valid.

subnet 192.168.0.0 netmask 255.255.255.0 {
        range 192.168.0.10 192.168.0.254;
        default-lease-time 3600;
        max-lease-time 4800;
        option routers 192.168.0.1;
        option domain-name-servers 192.168.0.1;
        option subnet-mask 255.255.255.0;
        option domain-name "l.brantleyonline.com";
        option time-offset -7;
        option ntp-servers 192.168.0.1;
        option netbios-name-servers 192.168.0.1;
        filename "pxelinux.0";
        next-server 192.168.0.1;
}

This would instruct every client that obtained a DHCP address in this subnet to download pxelinux.0 from 192.168.0.1 and then execute it (remember, that the next-server option is not required).

That's the basic dhcp setup required here. Either designate a single (or multiple) host to PXE boot by adding the filename parameter to its host block, or an entire subnet by adding it to its subnet block.

Remember to start your dhcp server (or restart) also :). Port 67/udp should be open when it's running, and likewise in order for the clients to obtain an address, be sure that this port is open to any client that may need it.

tftp-hpa

Personal tools
user accounts