From 0 to an OpenBSD install, with no hands and a custom disk layout

No one likes to do repetitive OS installs. You know the kind, where you are just clicking through a bunch of prompts for username, password, and partitioning scheme as fast as you can to quickly get to the point where you can get some work done. This scenario happens to me every time OpenBSD releases a new errata. As my OS of choice for firewalls/routers, I use a fresh OS install as the baseline for building a -stable branch of install set files.

While OpenBSD had automated away most of those manual-installation tasks with autoinstall(8), as of a week ago you still could not customize your disk layout. But thanks to commits by OpenBSD developers henning@ and rpe@,you can now specify your own disk layout programmatically to be used during an automated install.

While building a new set of install files is not part of this post, continue reading to see how I got one step  closer by completely automating the base OS install with my custom disk layout.

Using the below source presentation slide decks and Undeadly writeups, along with copius man page reading, my baseline infrastructure and configuration for a completely automated OpenBSD install is as follows:

DHCP server on local LAN configured to provide both an ‘auto_install’ and ‘next-server’ parameter. These two parameters point the pxe-booting host where to grab the code to run the next step of the install.

host openbsd-pxeboottest {    hardware ethernet 52:54:aa:bb:cc:dd;    filename "auto_install";    next-server; } 

Next was a tftp server prepared to handle the request for auto_install:

$ ps auxww -U _tftpd USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND _tftpd 16244 0.0 0.1 780 1172 ?? Is Wed06AM 0:10.14 /usr/sbin/tftpd -4 -l /tftp  $ ls -al /tftp/  total 14312 drwxrwxr-x 2 root wheel 512 May 8 19:46 . drwxr-xr-x 17 root wheel 512 May 6 06:24 .. lrwxr-xr-x 1 root wheel 7 May 6 06:25 auto_install -> pxeboot -rw-r--r-- 1 root wheel 7612185 May 8 21:37 bsd -rw-r--r-- 1 root wheel 80996 May 8 21:37 pxeboot 

The pxeboot and bsd files are the same ones from the install set.

Last but not least is install.conf, the file which contains the answers to the various questions OpenBSD presents during an install. This file must be in the root directory of an httpd server  configured above as ‘next-server’, in my case

Aside from all the normal answers for installation, the new prompt for auto-configuring disk layout is:

URL to autopartitioning template = 

Autodisklabel config:

/    100M-* 75% swap 10M-*  25% 

This config states, with minimums of 100MB for / and10MB for swap, configure the disk layout to provide 75% of its space for / and 25% of its space for swap.

The install should continue as expected and reboot at the end. Upon logging in, I verified the disk layout was what I wanted.

# disklabel -pm wd0 # /dev/rwd0c:... #  size    offset   fstype [fsize bsize cpg] a: 6159.5M 64       4.2BSD 2048 16384 1 # / b: 2029.8M 12614720 swap # none c: 8192.0M 0        unuse 

Based on a 8GB virtual disk file used for testing, ~6000MB for / and 2000MB for swap fits the bill.

Kudos to all the developers involved with this new functionality. I look forward to using it increasingly in the future.