$_ BSDHowTo.ch
How To... Why not..? Scripts Patches RSS logo

How to boot bsd.rd over the network

Last modified: 2018-08-27

Introduction

I show you how you can boot bsd.rd over the network. OpenBSD brings along all the tools you need for this in the base system. You need only one additional box that works as the server for DHCP and TFTP.

Configuration of tftpd(8)

The first step of the configuration of tftpd(8) is to choose a directory for tftpd(8). You will copy the required files to this directory and tftpd(8) will chroot(2) to it. Create it with the following commands:

$ doas mkdir /tftpboot

As a next step copy pxeboot(8) and /bsd.rd to the new directory:

$ doas cp /usr/mdec/pxeboot /tftpboot/
$ doas cp /bsd.rd /tftpboot/

Configuration of dhcpd(8)

When you boot a system using PXE it will first grab some configuration parameters from a DHCP server. The configuration of dhcpd(8) might look similar to this:

subnet 192.0.2.0 netmask 255.255.255.0 {
    default-lease-time 120;
    filename "pxeboot";
    max-lease-time 120;
    next-server 192.0.2.9;
    option domain-name "example.net";
    option domain-name-servers 192.0.2.11, 192.0.2.12;
    option routers 192.0.2.1;
    option subnet-mask 255.255.255.0;
    range 192.0.2.100 192.0.2.254;
    server-identifier 192.0.2.9;
}

The entries filename "pxeboot" and next-server 192.0.2.9 are the ones that pxeboot(8) requires. These contain the IP of the TFTP server to use and the file to fetch from it.

Configuration of boot(8)

The pxeboot(8) will try to load boot.conf(8) from the TFTP server. Like boot(8) it expects to find the file in the path /etc/boot.conf:

$ doas mkdir /tftpboot/etc
$ doas sh -c 'echo "boot tftp:bsd.rd" > /tftpboot/etc/boot.conf'

Of course you can add additional parameters to the file if you need to. If you install a headless box the following two entries might be required:

set tty com0
stty com0 115200

Start the required daemons

Once you are done with the configuration you must enable and start the two daemons. tftpd(8) requires the path to its directory as parameter.

$ doas rcctl enable tftpd
$ doas rcctl set tftpd flags /tftpboot
$ doas rcctl start tftpd
$ doas rcctl enable dhcpd
$ doas rcctl start dhcpd