From 8009e550630c3ec3169fbbaebefedfa9f4e4f6ed Mon Sep 17 00:00:00 2001 From: MickLesk <47820557+MickLesk@users.noreply.github.com> Date: Mon, 30 Nov 2026 12:56:02 +0100 Subject: [PATCH] VMs: allocate the EFI disk through vm_alloc_efi_disk allstarlink, alpine and opnsense still called pvesm alloc themselves and attached the zero-filled volume as efidisk0. On efitype=4m (Btrfs, or i440fx on any storage) OVMF's Secure Boot build faults on it and the VM never boots (#19205). The engine's helper now lets Proxmox allocate and initialize the disk; opnsense keeps its retry on zfs timeouts. --- vm/allstarlink-vm.sh | 2 +- vm/alpine-vm.sh | 2 +- vm/opnsense-vm.sh | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/vm/allstarlink-vm.sh b/vm/allstarlink-vm.sh index 089134e81..4ae0a9927 100644 --- a/vm/allstarlink-vm.sh +++ b/vm/allstarlink-vm.sh @@ -181,7 +181,7 @@ fi msg_info "Creating a AllStarLink VM" qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ -name $HN -tags community-script,debian${var_version},radio -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci -pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null +vm_alloc_efi_disk "$DISK0" qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null qm set $VMID \ -efidisk0 ${DISK0_REF}${FORMAT} \ diff --git a/vm/alpine-vm.sh b/vm/alpine-vm.sh index a6fe5ac91..b5eed51cb 100644 --- a/vm/alpine-vm.sh +++ b/vm/alpine-vm.sh @@ -142,7 +142,7 @@ fi msg_info "Creating an Alpine VM" qm create "$VMID" -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores "$CORE_COUNT" -memory "$RAM_SIZE" \ -name "$HN" -tags community-script -net0 virtio,bridge="$BRG",macaddr="$MAC""$VLAN""$MTU" -onboot 1 -ostype l26 -scsihw virtio-scsi-pci -pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null +vm_alloc_efi_disk "$DISK0" pvesm alloc "$STORAGE" "$VMID" "$DISK2" 4M 1>&/dev/null qm importdisk "$VMID" "$WORK_FILE" "$STORAGE" -format "$DISK_IMPORT_FORMAT" 1>&/dev/null qm set "$VMID" \ diff --git a/vm/opnsense-vm.sh b/vm/opnsense-vm.sh index 5192f486b..6704a3598 100644 --- a/vm/opnsense-vm.sh +++ b/vm/opnsense-vm.sh @@ -395,14 +395,16 @@ qm create $VMID -agent 1${MACHINE} -tablet 0 -bios ovmf${CPU_TYPE} -cores $CORE_ -name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC,firewall=0,queues=$CORE_COUNT$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci vm_mark_created -# Retry pvesm alloc on transient zfs_request "got timeout" errors (#14127) +# Retry on transient zfs_request "got timeout" errors (#14127) alloc_attempt=1 alloc_max=4 alloc_delay=5 while :; do - alloc_err=$(pvesm alloc $STORAGE $VMID $DISK0 4M 2>&1 >/dev/null) && break + # Not in $( ): vm_alloc_efi_disk sets DISK0_REF to the volume Proxmox made. + vm_alloc_efi_disk "$DISK0" 2>"/tmp/opnsense-efi-$$.err" && break + alloc_err="$(<"/tmp/opnsense-efi-$$.err")" if [[ "$alloc_err" == *"got timeout"* && $alloc_attempt -lt $alloc_max ]]; then - echo -e "${YW}[WARN]${CL} pvesm alloc hit zfs timeout (attempt $alloc_attempt/$alloc_max), retrying in ${alloc_delay}s..." + echo -e "${YW}[WARN]${CL} EFI disk allocation hit zfs timeout (attempt $alloc_attempt/$alloc_max), retrying in ${alloc_delay}s..." pvesm free "${DISK0_REF}" &>/dev/null || true sleep "$alloc_delay" alloc_attempt=$((alloc_attempt + 1)) @@ -412,6 +414,7 @@ while :; do msg_error "Could not allocate the EFI disk on ${STORAGE}: ${alloc_err}" exit 220 done +rm -f "/tmp/opnsense-efi-$$.err" vm_import_disk "$VMID" "$FILE" "$STORAGE" qm set $VMID \ -efidisk0 ${DISK0_REF}${FORMAT} \