Below is my work-in-progress code to take an openbsd cdXX.iso and inject the 
bare minimum necessary to autoinstall from a configuration file embedded in the 
image (it also reconfigures the console to run over the serial port - 
especially useful on a VM). There are no doubt better ways to do much of this 
but it's enough for me for the time being.

You will need an answers file. To automatically partition you will need to 
include this answer:

    URL to autopartitioning template for disklabel = file:/disklabel.template

Matthew

#!/bin/sh

# TODO: Get version from "$iso"
version=6.3

eval size=\$size_"$scheme"
eval sets=\$sets_"$scheme"

# OpenBSD's partitioning will be performed by the installer

# Only this stuff needs root, and only because the cd is _mounted_:
root vnconfig $loop "$iso"
root mount -o ro /dev/${loop}a "$mount"
# Needs root because bsd.rd is 750
root rsync -a --delete --exclude=TRANS.TBL "$mount"/ "$where"/cd/
root chmod -R a+rwX "$where"/cd
root umount "$mount"
root vnconfig -u $loop

echo set tty com0 >> "$where"/cd/etc/boot.conf

elfrdsetroot -x "$where"/cd/$version/amd64/bsd.rd "$where"/ramdisk
root vnconfig $loop "$where"/ramdisk
root mount /dev/${loop}a "$mount"
root cp "$libimage"/installer.openbsd "$mount"/auto_install.conf # .type for 
sets? ed?
root ed -s "$mount"/auto_install.conf <<EOF
/^Set name/s/=.*/= -* +b* $sets/
w
EOF
root cp "$libimage"/installer.openbsd-disklabel."$scheme" 
"$mount"/disklabel.template
root umount "$mount"
root vnconfig -u $loop
elfrdsetroot "$where"/cd/$version/amd64/bsd.rd "$where"/ramdisk

# From src/distrib/amd64/cdfs/Makefile
OSREV=$version # For easier copy pasta
mkhybrid -a -R -T -L -l -d -D -N -o "$where"/auto.iso -v -v          \
    -A "OpenBSD ${OSREV} amd64 autoinstall CD"                       \
    -P "Copyright (c) `date +%Y` Theo de Raadt, The OpenBSD project" \
    -p "Theo de Raadt <dera...@openbsd.org>"                         \
    -V "OpenBSD/amd64   ${OSREV} boot-only CD"                       \
    -b ${OSREV}/amd64/cdbr -c ${OSREV}/amd64/boot.catalog            \
    "$where"/cd
rm -fr "$where"/cd "$where"/ramdisk &

      # Questions: At what point does KARL clean up the other kernel's files?
      # When to set proxy and where?
      # syspatch on first boot
      # Password must be 13 *s

Reply via email to