aboutsummaryrefslogtreecommitdiffstats
path: root/openbsd-image
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2026-10-03 08:52:49 -0700
committerEugene Triguba <hello@eugenetriguba.com>2026-10-11 18:33:35 -0700
commitde40b1e69eaabac3ca01774fa3a4e7abc463ac7c (patch)
tree9e6ba70dd1f982f851c84a1aa542c1a28a55010f /openbsd-image
parentAdd prompt to remove build directory if it exists (diff)
downloadsite-server-images-de40b1e69eaabac3ca01774fa3a4e7abc463ac7c.zip
Customize the disk layout via disklabel templates
Diffstat (limited to 'openbsd-image')
-rw-r--r--openbsd-image/Makefile73
-rw-r--r--openbsd-image/disk-layouts/cgit.disklabel10
-rw-r--r--openbsd-image/locals.pkr.hcl1
-rw-r--r--openbsd-image/openbsd-amd64.pkr.hcl32
-rw-r--r--openbsd-image/openbsd-arm64.pkr.hcl32
-rw-r--r--openbsd-image/templates/install.conf.pkrtpl.hcl6
-rw-r--r--openbsd-image/variables.pkr.hcl6
7 files changed, 61 insertions, 99 deletions
diff --git a/openbsd-image/Makefile b/openbsd-image/Makefile
deleted file mode 100644
index 0c3ae00..0000000
--- a/openbsd-image/Makefile
+++ /dev/null
@@ -1,73 +0,0 @@
-# TODO: Replace with run-openbsd-image.sh and add ARM support to build-openbsd-image.sh
-SHELL := /bin/sh
-
-ARCH ?= arm64
-BUILD_DIR := build
-EDK2_DIR := /opt/homebrew/share/qemu
-SSH_PORT := 2222
-SSH_USER := admin
-SSH_KEY := ~/.ssh/id_rsa
-CPU := 8
-MEMORY := 32768M
-PACKER_LOG := 1
-
-VERSION := 7.9
-VERSION_SHORT := 79
-QEMU_ARCH := $(if $(filter arm64,$(ARCH)),aarch64,x86_64)
-VARS_FILE := openbsd$(VERSION_SHORT)-$(ARCH).pkvars.hcl
-DISK := $(BUILD_DIR)/openbsd-$(VERSION)-$(QEMU_ARCH).qcow2
-EFIVARS_RUN := $(BUILD_DIR)/efivars-run.fd
-EDK2_CODE := $(EDK2_DIR)/edk2-aarch64-code.fd
-EDK2_VARS := edk2-arm-vars.fd
-
-export PACKER_LOG
-
-.PHONY: all init build run ssh clean
-
-all: build
-
-init:
- packer init .
-
-build: init clean
-ifeq ($(ARCH),arm64)
- cp $(EDK2_DIR)/$(EDK2_VARS) ./$(EDK2_VARS)
-endif
- packer build -only qemu.openbsd-$(ARCH) -var-file=$(VARS_FILE) .
-
-# Run the headless VM (SSH via port-forwarded localhost:$(SSH_PORT))
-run:
-ifeq ($(ARCH),arm64)
- cp ./$(EDK2_VARS) $(EFIVARS_RUN)
- qemu-system-aarch64 \
- -machine type=virt,accel=hvf \
- -cpu host \
- -m $(MEMORY) \
- -smp $(CPU) \
- -nographic \
- -device qemu-xhci,id=xhci \
- -device usb-kbd,bus=xhci.0 \
- -device virtio-gpu-pci \
- -netdev user,id=net0,hostfwd=tcp::$(SSH_PORT)-:22 \
- -device virtio-net,netdev=net0 \
- -drive file=$(DISK),if=virtio,cache=writeback,discard=ignore,format=qcow2 \
- -drive file=$(EDK2_CODE),if=pflash,unit=0,format=raw,readonly=on \
- -drive file=$(EFIVARS_RUN),if=pflash,unit=1,format=raw
-else
- qemu-system-x86_64 \
- -machine type=q35,accel=tcg \
- -cpu max \
- -m $(MEMORY) \
- -smp $(CPU) \
- -nographic \
- -netdev user,id=net0,hostfwd=tcp::$(SSH_PORT)-:22 \
- -device virtio-net,netdev=net0 \
- -drive file=$(DISK),if=virtio,cache=writeback,discard=ignore,format=qcow2
-endif
-
-ssh:
- ssh -i $(SSH_KEY) -p $(SSH_PORT) $(SSH_USER)@127.0.0.1
-
-clean:
- rm -rf $(BUILD_DIR)
-
diff --git a/openbsd-image/disk-layouts/cgit.disklabel b/openbsd-image/disk-layouts/cgit.disklabel
new file mode 100644
index 0000000..b02585b
--- /dev/null
+++ b/openbsd-image/disk-layouts/cgit.disklabel
@@ -0,0 +1,10 @@
+/ 200M-1G 10%
+swap 1G-2G 0%
+/tmp 256M 0%
+/var 1G-3G 10%
+/var/log 200M-1G 0%
+/var/www 200M-5G 15%
+/usr 1G-4G 10%
+/usr/local 200M-4G 5%
+/home 100M-500M 0%
+/var/git 1G-* 50%
diff --git a/openbsd-image/locals.pkr.hcl b/openbsd-image/locals.pkr.hcl
index f88100f..a398219 100644
--- a/openbsd-image/locals.pkr.hcl
+++ b/openbsd-image/locals.pkr.hcl
@@ -1,4 +1,5 @@
locals {
version_short = replace(var.version, ".", "")
root_password = "temp"
+ http_port = 8900
}
diff --git a/openbsd-image/openbsd-amd64.pkr.hcl b/openbsd-image/openbsd-amd64.pkr.hcl
index 2fef98b..e19b208 100644
--- a/openbsd-image/openbsd-amd64.pkr.hcl
+++ b/openbsd-image/openbsd-amd64.pkr.hcl
@@ -17,18 +17,26 @@ source "qemu" "openbsd-amd64" {
ssh_password = local.root_password
ssh_timeout = "30m"
- http_content = {
- "/install.conf" = templatefile("${path.root}/templates/install.conf.pkrtpl.hcl", {
- hostname = var.hostname
- user = var.admin_user
- ssh_key = var.ssh_key
- root_password = local.root_password
- mirror = var.mirror
- version = var.version
- version_short = local.version_short
- arch = var.arch
- })
- }
+ http_port_min = local.http_port
+ http_port_max = local.http_port
+
+ http_content = merge(
+ {
+ "/install.conf" = templatefile("${path.root}/templates/install.conf.pkrtpl.hcl", {
+ hostname = var.hostname
+ user = var.admin_user
+ ssh_key = var.ssh_key
+ root_password = local.root_password
+ mirror = var.mirror
+ version = var.version
+ version_short = local.version_short
+ arch = var.arch
+ disklabel_template = var.disklabel_template
+ http_port = local.http_port
+ })
+ },
+ var.disklabel_template != "" ? { "/disklabel" = var.disklabel_template } : {}
+ )
boot_command = [
"<wait>S<enter><wait>",
diff --git a/openbsd-image/openbsd-arm64.pkr.hcl b/openbsd-image/openbsd-arm64.pkr.hcl
index a304426..b8845ff 100644
--- a/openbsd-image/openbsd-arm64.pkr.hcl
+++ b/openbsd-image/openbsd-arm64.pkr.hcl
@@ -17,18 +17,26 @@ source "qemu" "openbsd-arm64" {
ssh_password = local.root_password
ssh_timeout = "10m"
- http_content = {
- "/install.conf" = templatefile("${path.root}/templates/install.conf.pkrtpl.hcl", {
- hostname = var.hostname
- user = var.admin_user
- ssh_key = var.ssh_key
- root_password = local.root_password
- mirror = var.mirror
- version = var.version
- version_short = local.version_short
- arch = var.arch
- })
- }
+ http_port_min = local.http_port
+ http_port_max = local.http_port
+
+ http_content = merge(
+ {
+ "/install.conf" = templatefile("${path.root}/templates/install.conf.pkrtpl.hcl", {
+ hostname = var.hostname
+ user = var.admin_user
+ ssh_key = var.ssh_key
+ root_password = local.root_password
+ mirror = var.mirror
+ version = var.version
+ version_short = local.version_short
+ arch = var.arch
+ disklabel_template = var.disklabel_template
+ http_port = local.http_port
+ })
+ },
+ var.disklabel_template != "" ? { "/disklabel" = var.disklabel_template } : {}
+ )
boot_command = [
"<wait>S<enter><wait>",
diff --git a/openbsd-image/templates/install.conf.pkrtpl.hcl b/openbsd-image/templates/install.conf.pkrtpl.hcl
index 9df18ce..62a205a 100644
--- a/openbsd-image/templates/install.conf.pkrtpl.hcl
+++ b/openbsd-image/templates/install.conf.pkrtpl.hcl
@@ -12,5 +12,7 @@ HTTP Server = ${mirror}
Server directory = pub/OpenBSD/${version}/${arch}
Set name(s) = base comp man -game*.tgz -x*.tgz
Directory does not contain SHA256.sig. Continue without verification = no
-Change the default console to com0 = yes
-Which speed should com0 use = 115200
+Change the default console to com0 = no
+%{ if disklabel_template != "" ~}
+URL to autopartitioning template for disklabel = http://10.0.2.2:${http_port}/disklabel
+%{ endif ~}
diff --git a/openbsd-image/variables.pkr.hcl b/openbsd-image/variables.pkr.hcl
index e8340a9..0577253 100644
--- a/openbsd-image/variables.pkr.hcl
+++ b/openbsd-image/variables.pkr.hcl
@@ -59,3 +59,9 @@ variable "disk_size" {
description = "Size of the disk in GB while building the ISO"
default = 16
}
+
+variable "disklabel_template" {
+ type = string
+ description = "Specify a custom disklabel template. If empty (default), we'll use OpenBSD's default automatic layout."
+ default = ""
+}