FreeBSD PXEBoot Guide

Since I acquired a machine lately from my job that has no floppy drive or cdrom drive, I needed a way to load an operating system on it. It's one of these bbook sized servers and it's fairly powerful with an Intel 1Ghz processor and 512M of memory, so it's definitely a usable machine. Well, here's how you can use a FreeBSD server to allow a machine to PXEBoot on your network and load the kern.flp and mfsroot.flp floppies so that you can install an OS on it.

DHCPD

First off, you will need to install and configure isc-dhcp3 on your machine. The easiest way to install this is to go to /usr/ports/net/isc-dhcp3 and type make install as root. This will fetch the tar ball if you don't have it, compile it, and then install it.

Then, you will need to configure dhcpd.conf. Here's mine as an example:

ddns-update-style none;
subnet 66.13.175.240 netmask 255.255.255.248 {
  range 66.13.175.245 66.13.175.246;
  option subnet-mask 255.255.255.248;
  option broadcast-address 66.13.175.247;
  option routers 66.13.175.241;
  option domain-name-servers 66.13.175.242, 4.2.2.2, 4.2.2.1;
  option domain-name "ringofsaturn.com";
  default-lease-time 2592000;
  max-lease-time 2592000;
  server-name "DHCPserver";
  option root-path "/usr/tftpboot";
  filename "pxeboot";
}

Finally, you should copy /usr/local/etc/isc-dhcpd.sh.sample to /usr/local/etc/isc-dhcpd.sh and ensure that it's executable. Then just start the daemon up.

TFTP


Make a directory /usr/tftpboot
Add this line to your /etc/inetd.conf:
tftp    dgram   udp     wait    nobody  /usr/libexec/tftpd      tftpd -l /usr/tftpboot

Reboot to enable the new services or start them manually.

Bootstrap setup

Download the kern.flp and mfsroot.flp floppies from ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/i386/

Put pxeboot in the boot directory:

rm -rf /usr/obj/*
cd /usr/src/sys/boot
make
cp /usr/src/sys/boot/i386/pxeldr/pxeboot /usr/tftpboot

Using the vndevice mount the kern.flp file and copy its contents to /usr/tftpboot:


vnconfig vn0 kern.flp    # associate a vndevice with the file
mount /dev/vn0 /mnt      # mount it
cp -R /mnt /usr/tftpboot # copy the contents to /usr/tftpboot
umount /mnt              # unmount it
vnconfig -u vn0          # disassociate the vndevice from the file

Compile a custom the kernel (particularly to avoid the device config screen at boot) and stick it in /usr/tftpboot.

Make a special loader.rc to and install it in /usr/tftpboot/boot/loader.rc so that it doesn't prompt for the second disk, here's mine.

\ $Wintelcom: src/freebsd/pxe/doc/loader.rc,v 1.1 2000/07/15 07:20:37 bright Exp $
echo Loading Kernel...
load /kernel
echo Loading mfsroot...
load -t mfs_root /mfsroot
echo booting...
echo \007\007
echo initializing h0h0magic...
set vfs.root.mountfrom="ufs:/dev/md0c"
boot

Extract the installer and helper utilities from the mfsroot disk and uncompress them, put them in /usr/tftpboot as well:

vnconfig vn0 mfsroot.flp         # associate a vndevice with the file
mount /dev/vn0 /mnt              # mount it
cp /mnt/mfsroot.gz /usr/tftpboot # copy the contents to /usr/tftpboot
umount /mnt                      # unmount it
vnconfig -u vn0                  # disassociate the vndevice from the file
cd /usr/tftpboot                 # get into the pxeboot directory
gunzip mfsroot.gz                # uncompress the mfsroot

NFS

To be completely honest, I'm not sure if you need to run NFS or not to do this. All the articles I read talked about copying all of the contents of a CDROM of FreeBSD to your harddrive so that you can do an NFS install of the OS. Well, that's not what I wanted to do. I just needed to get to the point where I could run the sysinstall utility and do an FTP install from ftp2.freebsd.org.

So, if this doesn't work, then you'll need to enable NFSD by doing the following:

# echo "/usr -alldirs -maproot=root -ro" >> /etc/exports

If you have mountd running, then do the following:

# killlall -HUP mountd

If not, then you'll need to start it as follows:

# nfsd -t -u; mountd

To have nfs run at boot time, add nfs_server_enable="YES" to /etc/rc.conf and that should do it