Tutorial: FreeBSD network boot with mfsBSD (and pxelinux)

In this tutorial I am going to show how mfsBSD can be booted over the network. This tutorial expects the DHCP server (ISC) and TFTP server to be on a i386/amd64 FreeBSD machine using the same IP adress. If this is not the case, configuration may be different.

What do you need:

  • a boot server (DHCP, TFTP) with FreeBSD sources
  • mfsBSD (ISO from webpage or self-built)
  • some files from a installed sysutils/syslinux port (if you want pxelinux)
  • a network bootable (virtual) machine

A. Preparing the boot server (DHCP, TFTP)
The following examples expect a 192.168.0.0/24 network with gateway and dns-server at 192.168.0.1. If you are using different network parameters you have to adjust the configuration.

  1. Install the FreeBSD sources into /usr/src
  2. Install the port or package: net/isc-dhcp31-server or net/isc-dhcp41-server
  3. Example of a minimal /usr/local/etc/dhcpd.conf:
    authoritative;
    subnet 192.168.0.0 netmask 255.255.255.0 {
    	range 192.168.0.100 192.168.0.200;
    	option routers 192.168.0.1;
    	option domain-name-servers 192.168.0.1;
    	filename "pxeboot";
    }

    You may adjust the options to your needs and/or add another options.

  4. Enable the tftp daemon in your /etc/inetd.conf by uncommenting the following line:
    tftp	dgram		udp	wait	root	/usr/libexec/tftpd	tftpd -l -s /tftpboot
  5. Enable dhcpd and inetd by adding the following two lines to /etc/rc.conf:
    inetd_enable="YES"
    dhcpd_enable="YES"
  6. Create the /tftpboot directory
    # mkdir -p /tftpboot
  7. Extract the contents of the mfsBSD ISO image to /tftpboot
    # tar -x -C /tftpboot -f mfsbsd-8.2-amd64.iso
    # chmod -R go=u-w /tftpboot/*
    # chmod u+w /tftpboot/boot/loader.conf
  8. The standard loader in FreeBSD uses NFS instead of TFTP. In this tutorial, we will prepare a tftp-enabled loader. If you want to use the standard loader, you have to set-up a NFS server on the same IP address.
    # cd /usr/src/sys/boot
    # make clean && make depend && make -DLOADER_TFTP_SUPPORT
    # cp /usr/obj/usr/src/sys/boot/i386/pxeldr/pxeboot /tftpboot/pxeboot
  9. Start the inetd and dhcpd daemons
    # /etc/rc.d/inetd start
    # /usr/local/etc/rc.d/isc-dhcpd start
  10. You boot setup is ready, you can boot from network now!
    The file /tftpboot/boot/loader.conf can be customized to your needs.

B. Special: mfsBSD boot with pxelinux support
With pxelinux, you can get a nice boot menu and configure individual boot options for different computers or whole subnets. If you want to boot via pxelinux, do all the steps above („A. Preparing the boot server“) and continue with the following instructions:

  1. Install the port or package: sysutils/syslinux (you need only two files for step 2)
  2. Copy pxelinux.0 and menu.c32 into the /tftpboot directory
    # cp /usr/local/share/syslinux/pxelinux.0 /tftpboot/pxelinux.0
    # cp /usr/local/share/syslinux/menu.c32 /tftpboot/menu.c32
  3. Rename pxeboot to pexboot.0
    # mv /tftpboot/pxeboot /tftpboot/pxeboot.0
  4. Symlink pxelinux.0 to pxeboot
    # ln -s pxelinux.0 /tftpboot/pxeboot
  5. Create the /tftpboot/pxelinux.cfg directory
    # mkdir /tftpboot/pxelinux.cfg
  6. Create the file /tftpboot/pxelinux.cfg/default, example follows:
    default menu.c32
    allowoptions 0
    totaltimeout 100
    menu title Boot Menu
    label local
    	menu label Boot local system
    	localboot 0
    label mfsbsd
    	menu label mfsBSD
    	menu default
    	KERNEL pxeboot.0

    The parameter „totaltimeout 100“ fires the default option if no selection is made in 10 seconds.
    The parameter „allowoptions 0“ disables the TAB-key.

  7. Now you are ready to boot from chained pxelinux with a nice boot menu!

Alternative: NFS
To boot from NFS instead of TFTP, you need a working NFS server and the standard pxeboot.
Copy pxeboot from your /boot directory to /tftpboot:

# cp /boot/pxeboot /tftpboot/pxeboot

Add the following to the subnet section of /usr/local/etc/dhcpd.conf:

	option root-path "192.168.0.1:/tftpboot";

As of this example, the NFS server needs to run on 192.168.0.1 and the /tftpboot directory has to be NFS-exported.

Alternative: DHCP on a different server
If your TFTP server is on a different server than your DHCP server, you need to add the following line to the subnet section of /usr/local/etc/dhcpd.conf:

	option next-server "192.168.0.2";

In this example, your TFTP server is at 192.168.0.2.

Links:
mfsBSD Homepage
PXELINUX Wiki

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>