Much of the credit for this piece goes to m'mannn Nick 'Franga' Fratangelo, alias the PXE Pixie, who did most of the research and experimentation.
Prerequisites
- A working ISC DHCP - the DHCP service must be installed and working
- The PXE/TFTP Service goes on the DHCP Server (requires the dhcpd Daemon)
- The Ports Collection must be installed
- A working internet connection for grabbing updates
Software Required
- DHCP Service (ISC-DHCP3-Server) - as above
- TFTP-HPA from the ports collection
- PXE Linux Package syslinux-3.11.tar.gz (1.44MB, or updated equivalent)
- Not all installs are downloaded to the /src directory
1. Install the Ports Collection
We're using ports here because the port will pull down any dependencies it needs - and there are a few. This is one of the great things about installing from ports. Yeah-baby!
sysinstall
configure
distributions
ports
Wait for the system to finish loading ports from the CD to /usr/ports and then exit from sysinstall.
2. Install the TFTP Service
cd /usr/ports/ftp/tftp-hpa/
make install clean
Dependencies will be pulled from the internet and the whole install takes several minutes. Confirm any extra bits you want installed when the message box pops up. Note the final security message reported on screen..
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/bin/tftp
/usr/local/libexec/in.tftpd
3. Create the TFTP Directories
mkdir /tftpboot
mkdir /tftpboot/pxelinux
The system will expect to find the PXE stuff in
/tftboot, but most of the action happens from the
/pxelinux subdirectory, downwards.
4. Edit inetd.conf
vi /etc/inetd.conf
Uncomment this line..
#tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot
..and add the
-u nobody / bit to the end, to read:
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot -u nobody /
5. Setting up the TFTP Directories for PXE
Execute the following commands..
cd /src
tar -zxvf syslinux-3.11.tar.gz
cd syslinux-3.11
cp pxelinux.0 /tftpboot/pxelinux/
cp memdisk/memdisk /tftpboot/pxelinux/
mkdir /tftpboot/pxelinux/pxelinux.cfg (this
directory contains config/menu files)
mkdir /tftpboot/pxelinux/messages (directory where pxe messages are pulled from)
mkdir /tftpboot/pxelinux/images (directory where pxe floppy images are stored)
6. Configuring PXE
vi /tftpboot/pxelinux/pxelinux.cfg/default (this will be the default config file)
PROMPT 1 (gives a user prompt)
DEFAULT local (default label to boot)
DISPLAY defaultmessage (message to display to the user)
TIMEOUT 100 (timeout before booting to default)
label local (first label for localboot)
LOCALBOOT 0 (boots local disk)
label netboot (second label)
KERNEL memdisk keeppxe (which kernel to load, i.e. memdisk)
APPEND initrd=images/netboot.img (which image to load into memdisk)
label ghost (third label)
KERNEL memdisk keeppxe (which kernel to load, i.e. memdisk)
APPEND initrd=images/ghost.img (which image to load into memdisk)
Don't include the stuff in brackets in the
default file.
So..
default is the default menu file which the PXE system will boot, if the user doesn't type anything at the
boot: prompt. Note the 100 timeout = 10 seconds. As soon as the user types one character on the workstation, the
boot: prompt will wait indefinitely for that [enter] key..
After the first four lines, the rest of the file defines the
labels and what to do if one is selected. Each labels points to a corresponding
.img file, which is actually an image of a floppy disk (more below). If the user types
local [enter] at the
boot: prompt, the label tells the system to boot to the local hard disk. But if the user types
netboot, then the label points it to the
netboot.img and the contents of that file are executed. Add as many labels/.img files as required to perform various functions.
MEMDISK is a kernel loading program which manages the extraction and execution of the *.img file.
Next edit the default messages file..
vi /tftpboot/pxelinux/messages/default
..and add some friendly text:
Welcome to our PXE system
This is a message to you..
7. Modifying the DHCP service to use TFTP/PXE
vi /etc/dhcpd.conf and add the bold options from below..
# dhcpd.conf
# Allow PXE BootP
allow booting;
allow bootp;
# option definitions common to all supported networks...
option domain-name "it.net";
option domain-name-servers 10.0.0.1, 202.7.15.10;
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# Settings
option subnet-mask 255.0.0.0;
option broadcast-address 10.0.255.255;
option routers 10.0.0.2;
option domain-name-servers 10.0.0.1, 203.50.2.71;
option domain-name "it.net";
next-server 10.0.6.204;
filename "/pxelinux/pxelinux.0";
# Subnet Information
subnet 10.0.0.0 netmask 255.0.0.0 {
range 10.0.6.1 10.0.6.230;
range dynamic-bootp 10.0.7.1 10.0.7.230;
}
next-server 10.0.6.204;
- this is the tftp/pxe/dhcp server's IP Address
filename "/pxelinux/pxelinux.0";
- this is the pxe system's filename (actually inside /tftpboot/pxelinux/pxelinux.0)
range 10.0.6.1 10.0.6.230;
- the standard dynamic ip lease range
range dynamic-bootp 10.0.7.1 10.0.7.230;
- the standard bootp/pxe dynamic ip lease range
8. Creating a floppy disk image
We use a boot floppy disk based image to pass down the OS and other files to the user. Ours is a modified version of Bart Lagerweij's famous Network Boot Disk. Go to
Bart's Website and create a customised disk.
Firstly prepare a floppy disk on the target workstation to boot and perform as required. Once the floppy is running nicely, this will be turned into a PXE .img file. Insert the floppy into the BSD box and type..
dd if=/dev/fd0 of=/tftpboot/pxelinux/images/booter.img
This
takes an image from the floppy device (here: /dev/fd0 - yours may be
different) and writes it to the specified location to be referenced by a label (as noted in 6. Configuring PXE, above).
..And that's it. Reboot the FreeBSD DHCP/PXE Server and set those workstations to boot first to their network card/chip.
PXE Tweaks
Nick and I have developed a number of mods for this system, including doing something about all those pauses and prompts from the standard boot disk image. Once the system is working nicely, check out
Tweaking PXE.
References
http://www.webopedia.com/TERM/P/PXE.html
http://www.isgsp.net/freebsd/pxe.html
http://syslinux.zytor.com/pxe.php
http://syslinux.zytor.com/memdisk.php
http://www.kernel.org/pub/linux/utils/boot/syslinux/
http://www.isc.org/index.pl?/sw/dhcp/
http://www.nu2.nu/bootdisk/network/
- A&N.