TFTP Server for OpenBSD Installation
Introduction
We're going to set up a TFTP server to facilitate a network (PXE) installation of OpenBSD 4.9. In order to do so, we'll need a DHCP server running. When the machine we're performing the installation on boots up, and PXE boot is enabled in the BIOS, it will broadcast a DHCP request. The DHCP server will respond with an address for the install machine to use on the network, and a binary file that will be executed in order to boostrap the installation.
We'll be installing the DHCP and TFTP servers on an Ubuntu Lucid (10.04) machine, but the instructions should work just as well for a Debian install.
DHCP Server
Let's get the DHCP server installed:
$ sudo apt-get install dhcp3-server
You'll see this error:
* Starting DHCP server dhcpd3 * check syslog for diagnostics. [fail]
In order to see the error message, we'll run tail:
$ tail /var/log/syslog
This is what we find:
Sep 15 01:24:32 ubuntu dhcpd: No subnet declaration for eth0 (10.0.0.2). Sep 15 01:24:32 ubuntu dhcpd: ** Ignoring requests on eth0. If this is not what Sep 15 01:24:32 ubuntu dhcpd: you want, please write a subnet declaration Sep 15 01:24:32 ubuntu dhcpd: in your dhcpd.conf file for the network segment Sep 15 01:24:32 ubuntu dhcpd: to which interface eth0 is attached. ** Sep 15 01:24:32 ubuntu dhcpd: Sep 15 01:24:32 ubuntu dhcpd: Sep 15 01:24:32 ubuntu dhcpd: Not configured to listen on any interfaces!
So, we'll do exactly that. We'll change to the DHCP server's configuration directory and fire up our favorite text editor - we use vi in the example here, because it's everywhere. I've yet to find a UNIX-based system that didn't have vi installed. If you're not famililar with vi, it might be wise to read some introductory materials describing the different modes.
If you're on a Debian stable machine and have the isc-dhcp-server package installed, the config will instead be located in /etc/dhcp.
$ cd /etc/dhcp3 $ sudo vi dhcpd.conf
For the purposes of this install, we won't be contacting any outside servers (instead pulling the file sets off the machine that is hosting the TFTP server - we'll be serving them with apache2, since I already had it running). We can safely leave the domain-name options as they are. We will, however, need to change the subnet declaration. Uncomment it and change the address ranges to suit your LAN:
subnet 10.0.0.0 netmask 255.255.255.0 { range 10.0.0.100 10.0.0.199; option routers 10.0.0.2; option broadcast-address 10.0.0.255; }
Just make sure there aren't any other DHCP servers running on your network (for example, most consumer routers use DHCP to automatically configure your LAN - this is very straightforward to disable, however).
Next, we'll need to find the MAC address of the VirtualBox machine, since that's how the DHCP server is going to identify it. Go into settings for your VM, and go to Network. Pick the tab for the first adapter. Click on Advanced and you'll see the Mac Address field. The address will look something like this:
0800275253AC
Given that address, we want the configuration to look something like this:
host openbsd { option dhcp-client-identifier "openbsd"; fixed-address 10.0.0.100; hardware ethernet 08:00:27:52:53:ac; filename "pxeboot"; next-server 10.0.0.2; }
10.0.0.100 being the address we want to give our VM, and 10.0.0.2 being the address of the TFTP server. The filename option refers to the binary that will be executed on boot. This file will be served from our TFTP server.
Save your file, and now we'll restart the server:
$ sudo /etc/init.d/dhcp3-server restart
If everything went smoothly, the startup shouldn't fail this time.
* Stopping DHCP server dhcpd3 [fail] * Starting DHCP server dhcpd3 [ OK ]
TFTP Server
Next we need to get the TFTP server running.
$ sudo apt-get install atftpd
The configuration in Debian/Ubuntu is located in /etc/default/atftpd. It specifies that the files will be served from /srv/tftp. You can change this if you like, but we'll leave it as-is for the purposes of this installation. You can also specify whether or not you'd like to launch it through inetd, by setting the USE_INETD flag to false. On Debian Squeeze, it would have asked you during the install what you wanted to do, but on Ubuntu Lucid by default it uses inetd.
Now we need to get the TFTP daemon serving the OpenBSD installation files. Let's assume you've downloaded the 4.9 CD to your home directory.
$ sudo mkdir -p /mnt/install49 $ sudo mount -o loop ~/install49.iso /mnt/install49 $ sudo cp -r /mnt/install49/* /srv/tftp
Once the files are copied, make sure you're not in /mnt/install49 and unmount the ISO. We'll also get rid of the directory we made as a mount point.
$ sudo umount /mnt/install49 $ sudo rmdir /mnt/install49
There's still a couple files missing and/or not in the right place. Let's get them there. We need the pxeboot file that's going to bootstrap the whole install, and that's not available on the CD we downloaded. We'll also need a file named index.txt in order to satisfy the installer. This isn't on the CD, either.
$ cd /srv/tftp $ sudo wget http://ftp.openbsd.org/pub/OpenBSD/4.9/i386/pxeboot $ cd /srv/tftp/4.9/i386 $ sudo wget http://ftp.openbsd.org/pub/OpenBSD/4.9/i386/index.txt
The bsd.rd file contains a kernel and a compressed ramdisk containing a filesystem. We need that to be served directly from the root of our install, so we'll copy it there. (Don't move the file, it will also be needed where it is. We just want to make a copy.)
$ sudo cp /srv/tftp/4.9/i386/bsd.rd /srv/tftp/
Serving file sets
This completes the setup of the DHCP and TFTP servers. If you will initially have internet access on the install machine, and you'd like to use a public mirror, this will be sufficient for the install. In our case, since we're setting up a router, I won't initially depend on having a live internet connection. We'll want to set it up to serve these file sets from the same computer we've done the DHCP and TFTP stuff. We can do this one of two ways, either by setting up a local FTP server, or using a web server. Since I already have apache2 running and configured, I personally chose the HTTP route. I won't go into much detail about setting up and configuring apache2 - that's outside of the scope of this article. But essentially it involves adding a few lines to the configuration file for the particular site you want to serve it from. In my case, this file is located at /etc/apache2/sites-enabled/default, but this may vary. Consult your documentation or peruse the /etc/apache2 directory for clues. By default in Debian and Ubuntu the file will likely be called 000-default, rather than just default as I've mentioned is on my machine.
We'll want to add the following lines to the configuration file.
Alias /pub/OpenBSD /srv/tftp <Location /pub/OpenBSD> Options Indexes MultiViews FollowSymLinks SetHandler None </Location>
You can stick this at the end of the file, but make sure it's before the closing VirtualHost tag.
Save the file, and restart the apache2 server.
$ sudo /etc/init.d/apache2 restart
That's it! If everything is working, you should be able to run the install as described by my OpenBSD VirtualBox Guest Installation tutorial.
Last edited by localhorse on Jan. 2, 2012, 11:50 a.m. MST
