diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-11-14 15:59:57 -0800 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-11-14 16:00:04 -0800 |
| commit | 2dab373b6d14f3608c3431c261f70ab5facaaa50 (patch) | |
| tree | 0a52f0f5424ae1b001ead57f252c86f98a868f94 | |
| parent | Update readme to reference * subdomain instead of git (diff) | |
| download | site-server-images-2dab373b6d14f3608c3431c261f70ab5facaaa50.zip | |
Add support for custom disk format
| -rwxr-xr-x | build-openbsd-image.sh | 6 | ||||
| -rw-r--r-- | openbsd-image/openbsd-amd64.pkr.hcl | 4 | ||||
| -rw-r--r-- | openbsd-image/openbsd-arm64.pkr.hcl | 4 | ||||
| -rw-r--r-- | openbsd-image/variables.pkr.hcl | 10 |
4 files changed, 20 insertions, 4 deletions
diff --git a/build-openbsd-image.sh b/build-openbsd-image.sh index a7bce6f..7a0d634 100755 --- a/build-openbsd-image.sh +++ b/build-openbsd-image.sh @@ -46,6 +46,7 @@ main() ( -var "arch=$ARCH" \ -var "disk_size=$DISK_SIZE_GB" \ -var "version=$VERSION" \ + -var "disk_format=$DISK_FORMAT" \ -var "ssh_key=$(cat "$SSH_KEY")" \ -var "cpus=$(get_ncpus)" \ ${DISKLABEL_TEMPLATE:+-var "disklabel_template=$(cat "$DISKLABEL_TEMPLATE")"} \ @@ -71,6 +72,10 @@ parse_args() { DISK_SIZE_GB="$2" shift 2 ;; + --disk-format) + DISK_FORMAT="$2" + shift 2 + ;; --ssh-key) SSH_KEY="$2" shift 2 @@ -97,6 +102,7 @@ Options: --version VERSION OpenBSD version to build (default: $VERSION) --arch ARCH Target architecture: amd64 or arm64 (default: $ARCH) --disk-size-gb SIZE Disk size in GB (default: $DISK_SIZE_GB) + --disk-format FORMAT Format to use for the VM image (default: qcow2) --ssh-key PATH Path to SSH key (default: $SSH_KEY) --disklabel-template PATH Path to a custom disklabel autopartition template. If omitted, uses OpenBSD's default auto layout. diff --git a/openbsd-image/openbsd-amd64.pkr.hcl b/openbsd-image/openbsd-amd64.pkr.hcl index 7cbb24b..03e55e2 100644 --- a/openbsd-image/openbsd-amd64.pkr.hcl +++ b/openbsd-image/openbsd-amd64.pkr.hcl @@ -1,5 +1,5 @@ source "qemu" "openbsd-amd64" { - vm_name = "openbsd-${var.version}-amd64.raw" + vm_name = "openbsd-${var.version}-amd64.${var.disk_format}" iso_url = "${var.mirror}/pub/OpenBSD/${var.version}/${var.arch}/install${local.version_short}.iso" iso_checksum = "file:${var.mirror}/pub/OpenBSD/${var.version}/${var.arch}/SHA256" output_directory = "build" @@ -12,7 +12,7 @@ source "qemu" "openbsd-amd64" { disk_interface = "virtio" disk_size = "${var.disk_size}G" disk_compression = true - format = "raw" + format = var.disk_format ssh_username = "root" ssh_password = local.root_password ssh_timeout = "30m" diff --git a/openbsd-image/openbsd-arm64.pkr.hcl b/openbsd-image/openbsd-arm64.pkr.hcl index 3749486..b4d170c 100644 --- a/openbsd-image/openbsd-arm64.pkr.hcl +++ b/openbsd-image/openbsd-arm64.pkr.hcl @@ -1,5 +1,5 @@ source "qemu" "openbsd-arm64" { - vm_name = "openbsd-${var.version}-aarch64.qcow2" + vm_name = "openbsd-${var.version}-aarch64.${var.disk_format}" iso_url = "${var.mirror}/pub/OpenBSD/${var.version}/${var.arch}/install${local.version_short}.iso" iso_checksum = "file:${var.mirror}/pub/OpenBSD/${var.version}/${var.arch}/SHA256" output_directory = "build" @@ -12,7 +12,7 @@ source "qemu" "openbsd-arm64" { disk_interface = "virtio" disk_size = "${var.disk_size}G" disk_compression = true - format = "qcow2" + format = var.disk_format ssh_username = "root" ssh_password = local.root_password ssh_timeout = "10m" diff --git a/openbsd-image/variables.pkr.hcl b/openbsd-image/variables.pkr.hcl index 24fdbd1..6cd1c3a 100644 --- a/openbsd-image/variables.pkr.hcl +++ b/openbsd-image/variables.pkr.hcl @@ -60,6 +60,16 @@ variable "disk_size" { default = 16 } +variable "disk_format" { + type = string + description = "Format of the disk for the VM image" + default = "qcow2" + validation { + condition = contains(["raw", "qcow2"], var.disk_format) + error_message = "The arch must be one of: raw, qcow2." + } +} + variable "disklabel_template" { type = string description = "Specify a custom disklabel template. If empty (default), we'll use OpenBSD's default automatic layout." |