4 PXEBoot

4.1 Building the pxeboot loader

First we build the pxeboot loader with support for tftp, this means that the kernel will be fetched with tftp rather than mounting the nfs root filesystem first.

# cd /usr/src/sys/boot
# make -DLOADER_TFTP_SUPPORT=YES

Note: If you have compiled world and /usr/obj exists this won't build, remove or rename this directory first.

Install it into the tftp directory, /var/tftp:

# cp i386/pxeldr/pxeboot /var/tftp/boot/
# cp i386/boot0/boot0 /var/tftp/boot/
# cp i386/boot2/boot1 /var/tftp/boot/
# cp i386/boot2/boot2 /var/tftp/boot/
# cp i386/mbr/mbr /var/tftp/boot/

4.2 Building the kernel

For jumpstart installation we need the kernel to support tftp in order that it can fetch the root file system, this is a build option, the GENERIC kernel configuration file can be used without changes. For diskless systems, the GENERIC kernel supports NFS and NFS mount of the root file system, but additional BOOTP support will prove useful.

When configuring the kernel, make sure to include the network drivers for the client, or load them before boot. Also, make sure the following options are included in the kernel configuration file. For Jumpstart:

# Filesystems
options         MD_ROOT         # MD is a potential root device
options         PSEUDOFS        # Pseudo-filesystem framework

# Memory pseudo devices
device          md              # Memory "disks" needed for root file system

And for diskless operation:

options         NFSCLIENT
options         NFS_ROOT
options         BOOTP
options         BOOTP_COMPAT

The options BOOTP and BOOTP_COMPAT allow the kernel to rerequest certain options sent with the dhcp response such as hostname. Strictly, these are not required to boot the diskless system, but having the hostname set makes it easier to set host specific configuration option.

Build the kernel:

# cd /usr/src
# make -DLOADER_TFTP_SUPPORT=YES buildkernel

This builds a kernel with support for tftp. If you are compiling the kernel for a different version of FreeBSD than the server system, you need to "make buildworld" before building the kernel.

We will not overwrite our system kernel, instead we install directly into the directory /var/tftp. We first need to install a few files by hand:

# mkdir -p /var/tftp/boot/defaults
# cp /usr/src/sys/i386/conf/GENERIC.hints /var/tftp/boot/device.hints
# cp /usr/src/sys/boot/forth/loader.conf /var/tftp/boot/defaults/
# cp /usr/src/sys/boot/forth/loader.4th /var/tftp/boot/defaults/
# cp /usr/src/sys/boot/forth/support.4th /var/tftp/boot/defaults/

Note: Strictly, to install the kernel loader.4th and support.4th are not required, but we will include loader.4th in loader.rc and this includes support.4th.

Then install the kernel

# make DESTDIR=/var/tftp installkernel

4.3 The tftp root directory

In the tftp root directory, /var/tftp, create boot/loader.rc containing the following lines:

include /boot/loader.4th
start

For Jumpstart installation create boot/loader.conf containing the following:

init_path="/stand/sysinstall"
rootfs_load="YES"
rootfs_name="/boot/jumpstart"
rootfs_type="mfs_root"
vfs.root.mountfrom="ufs:/dev/md0c"
autoboot_delay=5

The loader will by default search first for init(8) and if not found then try to run sysinstall(8). Setting init_path allows us to toggle wether to run sysinstall or init at boot, provided both are present. You may add any kernel modules to be loaded with the usual syntax, in that case these are fetched with tftp and must be in the tftp directory.

The rootfs_name specifies that the loader should fetch the file /boot/jumpstart for use as root device, needed for jumpstart installation. Although the path appears absolute, on the server, this is relative to the tftp directory. In the next section we will create the root file system. You should not set any rootfs options, in fact no loader.conf is needed, the defaults will work fine.

If you try to boot at this stage, the pxeclient client should complete stage 3 and load the kernel.

This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.