3. Installing PXE

Abstract

This chapter describes how to install Mandriva Corporate Server 4 using the PXE (Pre-boot eXecution Environment) installation. You will learn how to configure the server and the client parts.

3.1. What is PXE?

PXE is a protocol designed by Intel that allows computers to boot across a network. PXE is stored in the ROM of recent generation network cards. When the computer boots up, the BIOS loads the PXE ROM into memory and executes it. From the menu displayed, choose an entry for the computer to boot on an operating system loaded through the network.

PXE is implemented by network card vendors following Intel's specification. The following figure represents how it works using a DHCP server and a TFTP server.

Figure 1.1. How PXE Works?

How PXE Works?

PXE follows 3 main steps to boot:

  • Obtain an IP address from the DHCP server

  • Download a bootstrap from the TFTP server

  • Execute the bootstrap

3.2. Using PXE to Install Mandriva Corporate Server 4

Using PXE is quite easy, you need to follow these steps:

Checking your hardware

First check your hardware so that it can use PXE functions. There is no universal way to do it. Your motherboard or network card documentation should specify it. You can also have a look in your BIOS settings, especially for onboard network devices. You will be able to enable or disable a “ROM option” on your network device (the specific method can be rather different depending on the BIOS). Also, in the boot order menu, make sure that the “network boot” is configured before the hard disk boot.

[Tip] Tip

Most recent computers allow you to choose network booting by pressing the F12 key at the beginning of the boot process.

Booting your system

If your PXE server is well configured, during the booting process, you should see all the 3 steps explained in the previous chapter. Then you should get a prompt: boot:. Enter the label of the system you want to install and that's it.

3.3. Configuring a PXE Server

Setting up PXE functions:

  • DHCP server

  • TFTP server

  • PXElinux bootstrap

  • NFS or HTTP server, we use NFS server in our example

3.3.1. Configuration of DHCP Server

This server answers a special DHCP request from the PXE client, depending on the PXE client class. The location of the log files varies according to your server's configuration. You can find them in /var/log/messages. The default configuration file is stored in the /etc directory.

3.3.1.1. dhcpd.conf Options

Here are classical options you need to configure:

Allow booting

The booting flag is used to tell dhcpd whether or not to respond to queries from a particular client. This keyword only has meaning when it appears in a host declaration. By default, booting is allowed, but if it's disabled for a particular client, that client won't be able to get an address from the DHCP server.

Not authoritative

If the server is not valid for that segment it will send a DHCPNACK message. This is important to set if you have other DHCP servers. If you want to install a PXE server in a network that already has a DHCP server, setting this option will insure that your DHCP answer will always be considered after the authoritative servers. This is usually used with a restricted PXE pool configuration (see below).

Pool

This section of /etc/dhcpd.conf defines a pool which contains a range of IP addresses. In our example, the DHCP server allows members of the Class PXE, and denies members of other classes. The sample configuration (see below) restricts the address pool to the PXE clients. This insures that your DHCP will not respond to normal DHCP requests. This allows you to install a PXE server without conflicting with the master DHCP server. If you want to offer IP addresses to normal DHCP and PXE requests, just comment the “Allow member of PXE” line.

The PXE boot server also needs specific options for the DHCP server to work properly:

Class

In our example, we create a PXE Class to determine specific options.

Option vendor-class-identifier

If the vendor-class-identifier option of the DHCP request equals PXEClient, this class matches.

Vendor-option-space

Defined to allow some specific options for the class.

Filename

Option filename defines the bootstrap client to retrieve. Our TFTP is chrooted so the path is relative to the chrooted directory only. Usually the file represents the PXElinux bootstrap. It's frequently called “linux.0” or “pxelinux.0”.

Next-server

It defines the IP of your TFTP server where the bootstrap and its configuration are stored.

Set vendor_class_identifier

Set the vendor-class-identifier field to PXEClient in the DHCP answer. If this field is not set, the PXE client will ignore the answer!

3.3.1.2. Sample from a Typical dhcpd.conf File
ddns-update-style ad-hoc;
allow booting;
allow bootp;
not authoritative;
 
# Definition of PXE-specific options
option space PXE;
option PXE.mtftp-ip code 1 = ip-address;
option PXE.mtftp-cport code 2 = unsigned integer 16;
option PXE.mtftp-sport code 3 = unsigned integer 16;
option PXE.mtftp-tmout code 4 = unsigned integer 8;
option PXE.mtftp-delay code 5 = unsigned integer 8;
option PXE.discovery-control code 6 = unsigned integer 8;
option PXE.discovery-mcast-addr code 7 = ip-address;
 				 
class "PXE" {
	 match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
	 #filename "/PXEClient/pxegrub";
	 filename "/PXEClient/pxelinux.0";
	 option vendor-class-identifier "PXEClient";
	 vendor-option-space PXE;
	 option PXE.mtftp-ip 0.0.0.0;
	 next-server 192.168.200.1;
	 }
				 
class "known" {
	 match hardware;
	 one-lease-per-client on;
	 ddns-updates on;
	 ddns-domainname = "mandriva.com";
	 ddns-hostname = pick-first-value(ddns-hostname, option host-name);
	 option fqdn.no-client-update on;
	 set vendor_class_identifier = option vendor-class-identifier;
	 }
				 
	 shared-network "mynetwork" {
	 subnet 192.168.200.0 netmask 255.255.255.0 {
	 option subnet-mask 255.255.255.0;
	 option routers 192.168.200.1;
	 default-lease-time 28800;
	 max-lease-time 86400;
	 
	 pool {
	 range 192.168.200.1 192.168.200.192;
	        allow members of "PXE";
	 }
 }
 }

    

3.3.2. Configuring the TFTP Server

The TFTP server contains the bootstrap and the configuration files. It's launched by the xinetd daemon. The default RPM installation usually works without modifying anything, except that it's not enabled by default. TFTP is managed by the xinetd daemon, so you need to specify that you want xinetd to open a dedicated port. The xinetd configuration for TFTP is in /etc/xinetd.d/tftp. Open this file and change disable=yes to disabled=no. Finally restart xinetd to take it into account: service xinetd restart.

3.3.3. Configuring PXElinux

PXElinux is the PXE bootstrap. This bootstrap is downloaded by the client PXE ROM and executed locally. The aim of this PXE bootstrap is to give a minimalist user interface for choosing the system you want to boot. PXElinux is provided by the SYSLINUX project. The bootstrap is usually named “pxelinux.0” or “linux.0”. Main features are:

  • You can define a config file for each PXE client IP address

  • The TFTP root directory is the one which contains pxelinux.0

  • Complies with the vendor-class-identifier requests

  • Boots a disk image (e.g. floppy disk image).

3.3.3.1. PXElinux tree
/var/lib/tftpboot	
   |-- X86PC
	|-- linux
		|-- help.txt
		|-- images
		|   |-- 2006.0
		|       |-- all.rdz
		|       `-- vmlinuz
		|-- linux.0
		|-- memdisk
		|-- messages
		|-- pxelinux.cfg
	    		|-- default
    

All the configuration files are stored in the /X86PC/linux directory of the TFTP server: /var/lib/tftpboot. You can create a subdirectory that contains all the files needed by the PXE client. The client is stored in /var/lib/tftpboot/X86PC/linux (PXEPATH). So your linux.0 should be in PXEPATH and set in the dhcp configuration file. Then create a pxelinux.cfg directory in PXEPATH (CFGPATH).

The configuration directory contains all the configuration files (one per PXE client IP address) or a “default” configuration file. The naming mechanism is to convert your IP address in hexadecimal form: 192.168.200.1 gives you the name of the “C0A8C801” CFGFILE. This file contains options for the PXE client so that it will make the request with its 192.168.200.1 IP address. You can use the gethostip script to do this conversion.

In PXEPATH, create a directory called images which will contain subdirectories for each boot system (e.g. linux for Linux boot images or a kernel and its initrd). Each of these contains a boot image or a kernel, its initrd and a help file.

3.3.3.2. Configuring PXElinux in pxelinux.cfg

The PXE client downloads the bootstrap (linux.0 in our case), executes it locally and then tries to download its configuration CFGFILE file. This file contains general options and boot images definition. Here are its main options:

DEFAULT kernel options

Sets the default command line. If PXELINUX boots automatically, it will act just as if the entries after DEFAULT had been typed in at the boot prompt, except that the option auto is automatically added, indicating an automatic boot.

DISPLAY filename

Displays the indicated file on the screen at boot time (before the boot prompt is shown).

TIMEOUT timeout

Indicates how long to wait at start-up. Timeout is canceled as soon as the user types anything on the keyboard, the assumption being that the user will complete the command line already begun. A timeout of zero completely disables the timeout, which is also the default behavior.

F[1-9] filename

When F[1-9] is pressed, then filename is displayed before going back to the prompt. It can be an easy way to provide help about boot images provided by the PXE server.

After having configured general options, we now need to define images provided by the PXE server. Each defined image starts with the label option. It contains strings that can be typed at the boot prompt. First, let's look at a specific image that can allow booting a local system by forcing the PXE client to exit.

label local
     LOCALBOOT 0

The general syntax is LOCALBOOT type. It executes a local disk boot instead of booting a kernel. The argument 0 means to perform a normal boot on the next boot device. The 4 argument performs a local boot with the Universal Network Driver Interface (UNDI) driver still resident in memory. Finally, the 5 argument performs a local boot with the entire PXE stack, including the UNDI driver, still resident in memory. All other values are undefined. If you don't know what the UNDI or PXE stacks are, don't worry, you don't want them: just specify 0.

label label
     KERNEL image
     APPEND options...
    

If label is entered as the kernel boots, PXElinux should instead boot image, and the specified APPEND options should be used instead of the ones specified in the global section of the file.

PXE can also allow you to boot the kernel directly. The PXE client will download (using a TFTP server) the kernel in the path given in the KERNEL option, then it downloads the initrd in the path given in the APPEND initrd= option.

Then the PXE client executes the kernel with the initrd and the option given by the APPEND option.

[Tip] Using PXE to test your memory

When you have problems installing or booting a server, you may want to check your main memory. PXE can help you by providing this function.

Get a memtest binary by installing the memtest86+ package:

# urpmi memtest86++

Then get the binary and copy it to the PXElinux tree:

# cp /boot/memtest-1.60.bin
      /var/lib/tftpboot/X86PC/linux/images/memtest-1.60

Finally add a new entry in the PXElinux configuration file:

label memtest kernel images/memtest-1.60

That's it! You will only need to boot your computer to test on a network device and enter memtest on the linux prompt.

3.3.3.3. Sample Configuration file

This file should be stored in CFGPATH and named like a CFGFILE (e.g. /var/lib/tftpboot/X86PC/linux/pxelinux.cfg/default or /var/lib//tftpboot/X86PC/linux/pxelinux.cfg/C0A8C801)

     PROMPT 1
     DEFAULT local
     DISPLAY messages
     TIMEOUT 50
     
     label local
     LOCALBOOT 0
				
     label linux
     KERNEL memdisk
     APPEND initrd=images/linux/network.img
     
     label memtest
     KERNEL images/memtest-1.60
     
     label autoinstall
     KERNEL images/autoinstall/vmlinuz 
     APPEND initrd=images/autoinstall/network.rdz ramdisk=32000 vga=788 kickstart=Mandrake/base/auto_inst.cfg.pl useless_thing_accepted automatic=method:nfs,network:dhcp,interface:eth0,dns:192.168.100.11,server:192.168.200.1,directory:/install root=/dev/ram3
     
     F1 images/local/help.txt
     F2 images/autoinstall/help.txt