Autoinstall (OpenBSD)

From Wiki
Revision as of 23:49, 13 August 2021 by Roman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Prologue

!! Work in progress !!

Of cause everything is well documented in dhcpd(8), tftpd(8), httpd(8), pxeboot(8), autoinstall(8), disklabel(8) and boot.conf(8).

Sequence

  1. PXE boot rom of the network adapter gets a dhcp response containing the fields filename and next-server
  2. Loads pxeboot from the installation server via tftp
  3. Executes pxeboot, which loads the installation system bsd.rd via tftp
  4. Boot loader fetches the boot configuration boot.conf via tftp
  5. Systemboot into the installation system
  6. autoinstall fetches the installation configuration install.conf via http
  7. Unattended automatic installation starts
  8. Installer gets disklabel.txt via http for partitioning
  9. install.site in side.tgz is executed
OpenBSD autoinstall files overview


Net Structure

Test Net Structure


tftpd

# mkdir -p /var/tftpboot/etc
# chmod -R _tftpd:_tftpd /var/tftpboot
# cp /usr/mdec/pxeboot /var/tftpboot/
# cp /bsd.rd /var/tftpboot/bsd
# chmod 644 /var/tftpboot/bsd
# cd /var/tftpboot
# ln -s pxeboot auto_install
# rcctl enable tftpd

In /etc/rc.conf.local:

tftpd_flags=-4 /var/tftpboot

Then:

# rcctl start tftpd

dhcpd

File /etc/dhcpd.conf:

option  domain-name "puffy.local";
option  domain-name-servers 10.0.1.1;

subnet 10.0.1.1 netmask 255.255.255.0 {
        option routers 10.0.1.1;

        range 10.0.1.100 10.0.1.200;

        host pxe0 {
                hardware ethernet E6:2F:16:43:D9:9D;
                filename "auto_install";
                next-server 10.0.1.2;
                fixed-address 10.0.1.150;
                option host-name "pxe0";
        }
}

Then:

# rcctl enable dhcpd
# rcctl start dhcpd

httpd

File /etc/httpd.conf:

server "default" {
        listen on 10.0.1.2 port 80
        root "/htdocs"
        directory auto index
}

Note: The root path is relative to /var/www!

Then:

# rcctl enable httpd
# rcctl start httpd

boot.conf

The /var/tftpboot/etc/boot.conf file is optional, the installation boot loader uses it for configuration purposes, e.g.

stty com0 115200
set tty com0
set timeout 5

Here the console output is switched from graphical to serial. I use a Proxmox VE virtualization host and I like to connect to my new virtual machines during installation:

# qm terminal <VM ID>

install.conf

File /var/www/htdocs/install.conf:

Password for root = $2b$11$2BGUZNcUlr/j/R2OKOSSw.gz.Y9lOqGbbzhBFnpZKHBu4IQexAa9q
Setup a user = no
Start sshd(8) by default? = yes
Allow root ssh login? = yes
Do you want the X Window System to be started by xenodm(1)? = no
URL to autopartitioning template for disklabel = http://10.0.1.2/disklabel.txt
What timezone are you in = Europe/Berlin
Location of sets = http
Set name(s) = -all bsd bsd.rd base*.tgz man*.tgz site*.tgz
HTTP Server = 10.0.1.2
Server directory? = pub/OpenBSD/6.9/amd64
Unable to connect using https. Use http instead? = yes
INSTALL.amd64 not found. Use sets found here anyway? = yes
Directory does not contain SHA256.sig. Continue without verification? = yes
  • Password with encrypt

disklabel

File /var/www/htdocs/disklabel.txt:

/       1G
swap    256M
/usr    3G
/var    3G
/home   1G
/tmp    1G

site.tgz

File install.site:

#!/bin/sh

rcctl disable slaacd
rcctl disable ntpd
rcctl disable smtpd
rcctl disable sndiod
rcctl disable pflogd

echo "library_aslr=NO" >> /etc/rc.conf.local
echo "https://ftp.fau.de/pub/OpenBSD" > /etc/installurl
echo "" > /etc/motd

Then:

# chmod 755 install.site
# tar cfz site69.tgz install.site

Mirror

I think it's a good idea to have a minimal local mirror. While you can change the path to the file sets, I kept the default one. I normally only install bsd, bsd.rd and base*.tgz, but sometimes it is nice to have comp*.tgz and man*.tgz too. For me, there is no need for the X11 packages, because I only use OpenBSD in VMs. The following commands create a minimal repository:

# mkdir -p /var/www/htdocs/pub/OpenBSD/6.9/amd64
# cd /var/www/htdocs/pub/OpenBSD/6.9/amd64
# for file in "bsd" "bsd.mp" "bsd.rd" "base69.tgz" "comp69.tgz" "man69.tgz"; do ftp https://cdn.openbsd.org/pub/OpenBSD/6.9/amd64/$file; done
# ls -ln > index.txt

Note the index.txt, which is very important because the installer looks for it to determine the available file sets.

First boot

  • Boot loader: boot sd0a:/bsd

Debug

  • Autoinstaller
    • DHCP leases file: /var/db/dhclient.leases.vio0

Demonstration