Netboot

Booting a computer over the network may be necessary (or just convenient). OpenBSD has the tools to do this in the basic install. On X86 or AMD64 computers the standard way of netbooting is PXE.

PXE Boot

This is normally configured in the BIOS (or whatever these modern UEFI thingys call it) setup to boot first from the network.

When the computer netboots, first it uses DHCP to configure the network interface. This gets it an address, and the information it needs to start the boot process. It then loads the file DHCP told it to get, from the server DHCP told it to use. This file is executed to load the next step, normally loading the kernel and executing it.

Network Install

To install OpenBSD on an X86 (or AMD64) you need to set up a PXE boot server. This uses DHCP to tell the target computer what network address to use and what file to load. If you don't have control of the network to configure DHCP, it's best to make a seperate network for this. You can use a CAT5 crossover cable, or if one of the computers has Gigabit ethernet it works with an ordinary CAT5 cable. You can also just use a small ethernet switch for your little two computer LAN.

On the install server, configure DHCP. For example on my install server at 192.168.2.2 a minimal /etc/dhcpd.conf would have:

 subnet 192.168.2.0 netmask 255.255.255.0 {
                filename "pxeboot";
                next-server 192.168.2.2;
                range 192.168.2.32 192.168.2.127;
 }

Also check /etc/rc.conf.local to ensure dhcpd starts using the interface you want to use. e.g. if your interface is gem0 add the line

dhcpd_flags="gem0" 

Now start the DHCP daemon.

$ doas rcctl enable dhcpd
$ doas rcctl start dhcpd

This gives any computer requesting DHCP an address in the range 192.168.2.32 to 192.168.2.127 and tells it to request the file 'pxeboot' from the server at 192.168.2.2. The file is requested via TFTP.

We'll need the tftp daemon setup and running. The tftp daemon uses /tftpboot by default, so you'll need to create it and make the tftpd user the owner.

$ doas mkdir /tftpboot
$ doas chown _tftpd /tftpboot

As with DHCP, we'll need to configure TFTPD to start.

$ doas rcctl enable tftpd
$ doas rcctl start tftpd

HTTP server

Now we need some files for the boot and install process. Assuming we're going to install on AMD64 we'll need the amd64 install directory. May as well create the directories on the local http server and load them up.

Create a config file /etc/httpd.conf.

server "v240.home.arpa" {
        listen on * port 80
        root "/htdocs"
        directory auto index
        log style combined
}

Make the install directory.

doas mkdir -p /var/www/htdocs/pub/OpenBSD/7.0/amd64

Start the http server.

doas rcctl enable httpd
doas rcctl start httpd

Populate this directory with the relevant files from one of the mirrors. I normally don't get the .iso or .fs files as they're not used. This script will gab the files.

#! /bin/sh
MIRROR=https://ftp.openbsd.org/pub/OpenBSD/7.0/amd64/
ftp ${MIRROR}index.txt
for FILE in `cut -c 55- index.txt | grep -v .iso | grep -v .fs`
do
 ftp ${MIRROR}${FILE}
done

Copy pxeboot and bsd.rd to /tftpboot. Rename bsd.rd to bsd so it will be loaded by default.

$ cd /var/www/htdocs/pub/OpenBSD/7.0/amd64
$ doas cp pxeboot bsd.rd /tftpboot
$ doas mv /tftpboot/bsd.rd /tftpboot/bsd

Now you should be able to boot your AMD64 computer on your little network. It will get a network address over DHCP, then try to load pxeboot using tftp. pxeboot will load bsd, which in this case is actually bsd.rd, the installer. At this point the install continues as normal. Use the IP address of your server as the install server, in this case that's 192.168.2.2. It should say that HTTPS doesn't work and you tell it to continue with HTTTP. Then it should find the install files and you can complete the install.

Once you've completed the install, reboot and reconfigure the BIOS to boot from disk. Unplug from your setup network and plug the network into the Internet connected network. Boot it up and it should be good to go.