FreeBSD 13 installation over PXE

This article provides an example config and procedure to set up FreeBSD DHCP/TFTP/NFS server so other machines on the network can boot over PXE, and install FreeBSD without using a USB memory stick or CD.

This article assume that

  • Your gateway is
  • FreeBSD DHCP/TFTP/NFS server you’re trying to setup here is

Copy files from LiveCD or memstick

mount -o ro /dev/da0s2a /mnt  # or mount_cd9660 /dev/cd0 /mnt

mkdir /tftpboot
cp -a /mnt /tftpboot/FreeBSD

echo " / nfs ro 0 0" > /tftpboot/FreeBSD/etc/fstab  # NFS rootfs location
echo 'beastie_disable="YES"' >> /tftpboot/FreeBSD/boot/loader.conf  # on legacy boot, beastie may show up but countdown stuck at 10 seconds

umount /mnt

Configure static IP (FreeBSD DHCP/TFTP/NFS server)

Edit /etc/rc.conf and add the following lines

# remove ifconfig_em0="DHCP" and change it to
ifconfig_em0="inet netmask"

Setup DHCP server

Option 1: use isc-dhcpd on FreeBSD

Install DHCP server on FreeBSD by running pkg install isc-dhcp44-server

Edit config file /usr/local/etc/dhcpd.conf

subnet netmask {
   option subnet-mask;
   option routers;
   option broadcast-address;
   option domain-name-servers,;

   next-server;  # TFTP server IP
   filename "FreeBSD/boot/pxeboot";  # legacy boot
   # filename "FreeBSD/boot/loader.efi";  # UEFI boot
   option root-path "";  # NFS server IP and path

Configure DHCP server to start on boot, and start DHCP server

echo 'dhcpd_enable="YES"' >> /etc/rc.conf
service isc-dhcpd restart

Option 2: use EdgeRouter

set service dhcp-server shared-network-name LAN subnet bootfile-server  # TFTP server IP
set service dhcp-server shared-network-name LAN subnet bootfile-name FreeBSD/boot/pxeboot  # legacy boot
# set service dhcp-server shared-network-name LAN subnet bootfile-name FreeBSD/boot/loader.efi  # UEFI boot

# Because "root-path" is not available in EdgeRouter config, we define option 17 here
set service dhcp-server global-parameters 'option option-17 code 17 = string;'
set service dhcp-server shared-network-name LAN subnet subnet-parameters 'option option-17 "";'

Setup TFTP server

Edit /etc/inetd.conf and uncomment line tftp dgrm udp...

And configure TFTP server to start on boot, and start TFTP server

echo 'inetd_enable="YES"' >> /etc/rc.conf
service inetd start

Setup NFS server

echo '/tftpboot -ro -alldirs -maproot=root' > /etc/exports
echo 'nfs_server_enable="YES"' >> /etc/rc.conf
service nfsd start

Done. Machines on the network should be able to boot over PXE.

For detail, please refer to chapter 32.8 “Diskless Operation with PXE” in FreeBSD handbook.

Note: If you’re testing it in libvirt and it’s UEFI PXE boot, and the video console stopped at “lo0: link state changed to UP”, with “Dual Console: Serial Primary, Video Secondary” a few lines before, check your serial console at “virsh console VM_NAME”.

Leave a Reply

Your email address will not be published. Required fields are marked *