aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md74
1 files changed, 74 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c9e85ab
--- /dev/null
+++ b/README.md
@@ -0,0 +1,74 @@
+# OpenBSD Packer Template
+
+This repository contains a template for building OpenBSD boxes for QEMU using Packer.
+
+It may work for other configurations with additional variables added and some
+variables changed. However, I only use it for running OpenBSD on an ARM Mac, so
+that is the only configuration that is actively tested.
+
+## Installation
+
+You can also build the box yourself with the following:
+
+```sh
+brew install qemu
+cp /opt/homebrew/share/qemu/edk2-arm-vars.fd ./edk2-arm-vars.fd
+export PACKER_LOG=1
+packer init
+packer build -var-file=openbsd79-arm64-macos.pkvars.hcl
+```
+
+## Usage
+
+Once your image is built, you can run it.
+
+First, the efivars are stateful. So, make a copy of the ones you used during the
+build to use for your particular run.
+
+```sh
+cp build/efivars.fd build/efivars-run.fd
+```
+
+Then, run the following command:
+
+```sh
+qemu-system-aarch64 \
+ -machine type=virt,accel=hvf \
+ -cpu host \
+ -m 4096M \
+ -smp 1 \
+ -nographic \
+ -device qemu-xhci,id=xhci \
+ -device usb-kbd,bus=xhci.0 \
+ -device virtio-gpu-pci \
+ -netdev user,id=net0,hostfwd=tcp::2222-:22 \
+ -device virtio-net,netdev=net0 \
+ -drive file=build/openbsd-7.9-aarch64.qcow2,if=virtio,cache=writeback,discard=ignore,format=qcow2 \
+ -drive file=/opt/homebrew/share/qemu/edk2-aarch64-code.fd,if=pflash,unit=0,format=raw,readonly=on \
+ -drive file=build/efivars-run.fd,if=pflash,unit=1,format=raw
+```
+
+If you want a display (rather than a headless VM over SSH), replace `-nographic`
+with `-display cocoa`.
+
+Once the system is up, you can SSH in using your admin user and private key:
+
+```sh
+> ssh -p 2222 eugene@127.0.0.1
+The authenticity of host '[127.0.0.1]:2222 ([127.0.0.1]:2222)' can't be established.
+ED25519 key fingerprint is: SHA256:GnVug9cxjtROdVCbDsaxG7Co/E1j060B9U+bmY2lqOk
+This key is not known by any other names.
+Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
+Warning: Permanently added '[127.0.0.1]:2222' (ED25519) to the list of known hosts.
+OpenBSD 7.9 (GENERIC) #211: Wed May 6 17:30:57 MDT 2026
+
+Welcome to OpenBSD: The proactively secure Unix-like operating system.
+
+Please use the sendbug(1) utility to report bugs in the system.
+Before reporting a bug, please try to reproduce it with the latest
+version of the code. With bug reports, please try to ensure that
+enough information to reproduce the problem is enclosed, and if a
+known fix for it exists, include that as well.
+
+openbsd-vm$
+```