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 192.168.0.1
- FreeBSD DHCP/TFTP/NFS server you’re trying to setup here is 192.168.0.2
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 "192.168.121.2:/tftpboot/FreeBSD / 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 192.168.0.2 netmask 255.255.255.0" defaultrouter="192.168.0.1"
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 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.10 192.168.0.19; option subnet-mask 255.255.255.0; option routers 192.168.0.1; option broadcast-address 192.168.0.255; option domain-name-servers 8.8.8.8, 1.1.1.1; next-server 192.168.0.2; # TFTP server IP filename "FreeBSD/boot/pxeboot"; # legacy boot # filename "FreeBSD/boot/loader.efi"; # UEFI boot option root-path "192.168.0.2:/tftpboot/FreeBSD/"; # 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 192.168.0.0/24 bootfile-server 192.168.0.2 # TFTP server IP set service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 bootfile-name FreeBSD/boot/pxeboot # legacy boot # set service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 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 192.168.0.0/24 subnet-parameters 'option option-17 "192.168.0.2:/tftpboot/FreeBSD/";'
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”.