TFTP: PXE Server, OS Deployment under Linux
Introduction
PXE boot (Pre-boot eXecution Environment) allows a workstation to boot from the network an operating system that is stored on a server.
It also allows automatic and remote installation of servers with various operating systems.
To enable PXE, you first need to configure it in the BIOS. The option is frequently found in a menu related to the network card.
PXE booting is performed in several steps:
- Search for an IP address on a DHCP server as well as the file to boot
- Download the boot file from a Trivial FTP server
- Execute the boot file
It should be noted that the size of the boot file does not allow for directly booting a Linux kernel, for example, but requires that the boot software download and execute it itself.
Prerequisites
The prerequisites are quite simple; you just need a DHCP server that is able to boot on PXE. We will see here the configuration of this DHCP server so that it accepts network booting.
Installation
To install the PXE server:
|
|
Configuration
tftpd-hpa
We will edit the file /etc/default/tftpd-hpa
to replace the value of RUN_DAEMON:
|
|
Inetd
We disable the tsize of tftp-hpa which limits the size of files to be downloaded. For this, add a line in /etc/inetd.conf
and check that another one is commented out:
|
|
Once done, we will restart inetd and tftpd:
|
|
To verify that everything is working:
|
|
If the line above appears, everything went well :-)
Iptables
Here’s the nice line to add to iptables to allow tftp:
|
|
DHCP under Linux
If your DHCP is under Linux, edit the /etc/dhcp3/dhcpd.conf
file and add these lines in your subnet:
|
|
Next-server is to specify the IP address of the PXE server.
Then restart your DHCP server:
|
|
DHCP under Windows
If your DHCP is under Windows, in your DHCP configuration (general or not), add the address of the TFTP server.
Boot loader
Now, we must prepare and organize our TFTP server:
|
|
We have inserted pxelinux.0, which is essential for booting our OSes, and menu.c32, which provides a basic but practical menu when we have our OSes installed.
Let’s configure the global configuration of the server. Create and edit the file pxelinux.cfg/default to insert this:
|
|
The basic configuration is now ready. We only need to add operating systems.
Setting up Operating Systems
Let’s see how to set up different types of operating systems. Before continuing, go to this folder:
|
|
Debian
Let’s create what we need, that is, a folder, and then insert the kernel. We’ll do both the 32-bit and 64-bit versions:
|
|
For the 32-bit version:
|
|
For the 64-bit version:
|
|
Then add these lines (depending on the architecture you have chosen) in the file /var/lib/tftpboot/pxelinux.cfg/default
:
|
|
- vga=791: loads 1024*768 resolution
- priority=low: loads Debian expert mode
Note: To automate installations, follow this link: Automate a Debian installation.
Memtest86+
At the time of writing, the latest version is 1.70. So I’ll use this for my example:
|
|
Let’s download this version (we’ll take the bootable binary):
|
|
Then a small subtlety, we need to rename and remove the .bin for it to work:
|
|
Then add these lines (depending on the architecture you have chosen) in the file /var/lib/tftpboot/pxelinux.cfg/default
:
|
|
OpenBSD
Again, we’ll do what’s necessary to be able to launch OpenBSD in 32-bit and 64-bit versions:
|
|
For the 32-bit version:
|
|
For the 64-bit version:
|
|
We’re using the floppy versions here and not the CD versions because we’ll be using a new module called memdisk that can load an ISO but only smaller than the size of a floppy disk. So copy this module:
|
|
Then add these lines (depending on the architecture you have chosen) in the file /var/lib/tftpboot/pxelinux.cfg/default
:
|
|
Red Hat
Red Hat is a bit special because we’ll need to create a DVD, then copy it to insert the kernel. We’ll do the 32-bit and 64-bit versions:
|
|
Create the DVD, then copy it to the proper directory according to your version (32 or 64 bits).
For the 32-bit version:
|
|
For the 64-bit version:
|
|
Then add these lines (depending on the architecture you have chosen) in the file /var/lib/tftpboot/pxelinux.cfg/default
:
|
|
- vga=791: loads 1024*768 resolution
Password Protection
The SYSLINUX archive contains an executable called sha1pass (it’s a Perl script) that generates passwords in the correct format. To use it under Debian, you need the appropriate Perl module:
|
|
Then run the command with the password as a parameter and it will give us the string to paste into the configuration file. For example, to protect Ghost:
|
|
Resources
Last updated 20 May 2010, 05:14 CEST.