Custom Installation

OpenBSD offers the option to customize the installation process in multiple ways:

  • Add specific, non-OpenBSD, files to complement, supplement, or modify the default installation
  • Execute commands during and/or after the installation process has completed
  • Perform an unattended installation by providing an answer file

The siteXX.tgz File Set #

It’s possible to add user-created files to the installation. This can be done via a set called siteXX.tgz. Like the official OpenBSD sets, this set is a tar archive rooted in / and will be unpacked with the -xzphf tar options. Since it’s installed last, it can be used to overwrite or otherwise modify the default installation files as well as adding new files to it. It’s also possible to provide a host specific set by simply naming it like siteXX-$(hostname -s).tgz where hostname -s provides the short hostname.

There are multiple tools available to help with creating these sets.

  • The first one is SiteXYTools and can be found here.
  • The second tool was inspired by SiteXYTools, is called sxxu (SiteXX Utility) and can be found here.

The install.site and upgrade.site Scripts #

In order to execute commands at install or upgrade time, you can install an executable named /install.site or /upgrade.site respectively. The file /install.site should be placed in the siteXX.gz while the /upgrade.site file can be placed in the root directory of the system before rebooting to start the upgrade.

There are multiple reasons why this can be useful:

  • To add itself to a loadbalancer pool
  • To notify an admin of a successful installation
  • To run arbitrary commands
  • To run arbitrary one time commands via rc.firsttime
  • Perform self checks

Unattended installation #

OpenBSD provides the option to supply answers to the installer questions in a file. The name of the system is autoinstall and allows for unattended OpenBSD installations and upgrades.

The system works by providing an answer of response file to the installer. The installer will look for the answer file after the (A)utoinstall option is chosen after booting the bsd.rd kernel or when a netboot is performed and the user does not perform an action for a certain amount of time.

The information on where to look is provided to the installer via DHCP. The server hosting the file can be specified with one of the following DHCP options:

  • server-name
  • option tftp-server-name
  • next-server

The filename can be specified with:

  • filename
  • option bootfile-name

Additionally, you can specify the hostname to be used during the installation with:

  • option-host-name

An example of a install.conf file can be found below.

System hostname = foo
Password for root = $2b$14$Z4xRMg8vDpgYH...GVot3ySoj8yby
Change the default console to com0 = yes
Which speed should com0 use = 19200
Setup a user = bar
Password for user = *************
Public ssh key for user = ssh-rsa AAAAC3NzaC1...uer37Adr foo@bar
What timezone are you in = Europe/Amsterdam
Location of sets = http
HTTP Server = cdn.openbsd.org

An example of a host declaration on the DHCP server:

host foo {
  hardware ethernet 00:00:00:00:00:00;
  fixed-address 192.168.1.100;
  filename "auto_install";
  option host-name "foo";
  option tftp-server-name "server1";
}