QEMU - Windows unable to boot in UEFI mode

I’m trying to build qcow2 format image for Windows server 2025 and when asking Packer to use UEFI mode, it’s unable to boot from ISO and it just drops me in EFI Shell where I see the content of the ISO is FS1: not in FS0:

I’m able to boot form ISO in BIOS mode but want to build image in UEFI mode.

here is my packer script

packer {
  required_version = ">= 1.11.0"
  required_plugins {
    qemu = {
      version = ">= 1.1.1"
      source  = "github.com/hashicorp/qemu"
    }
  }
}

source "qemu" "windows" {
  vm_name                = "panw-cisl1-windows-2025"
# Windows 2025  - Internet
  # iso_url                = "https://artifactory.paloaltonetworks.com:443/artifactory/openshift-images-local/26100.1742.240906-0331.ge_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso"
  # iso_checksum           = "d0ef4502e350e3c6c53c15b1b3020d38a5ded011bf04998e950720ac8579b23d"
# Windows 2025 - Thomas image
  iso_url                = "https://artifactory.paloaltonetworks.com/artifactory/openshift-images-local/SW_DVD9_Win_Server_STD_CORE_2025_24H2.9_64Bit_English_DC_STD_MLF_X24-08243.ISO"
  iso_checksum           = "2509618770af72a6335f975beb9f3caacfecbd60c448cafa37959aabccb0d12d"
# Windows 2025 with autounattended

  format                 = "qcow2"
  output_directory       = "build"
  machine_type           = "q35"
  accelerator            = "kvm"
  cpus                   = "4"
  memory                 = "14096"
  disk_size              = "40960M"
  headless               = "true"


qemuargs = [
  ["-drive", "file=/home/jenkins-agent/.cache/packer/45173890bb9e0fc063f71cfb6d5ec40a0210e2d9.iso,media=cdrom,index=4"],
  ["-drive", "if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd"],
  ["-drive", "if=pflash,format=raw,file=/home/jenkins-agent/ovmf/OVMF_VARS.fd"],
  ["-boot", "order=d"]
]
  communicator           = "winrm"
  winrm_username         = "Administrator"
  winrm_password         = "WindowsPassword"

  net_device = "e1000"
  disk_interface         = "ide"
  floppy_files = ["../answer-files/autounattend.xml", "../answer-files/winrm-config.ps1"]
  boot_command = ["<spacebar><spacebar>"]


any idea why ?

Can you test with different values of the disk_interface

trying scsi, virtio, and virtio-scsi didn’t help

It seems like in UEFI, the EFI shell is first in the boot order. I don’t think its possible to alter this in UEFI today in packer. Perhaps need to figure out a workaround.

As a workaround, u can try running fs1:\bootmgr.efi as the first boot_command in packer. This will hopefully boot the right iso.
Additionally add a wait for maybe 60s <wait60> after this to let the iso boot.

@anurag.sharma

source "qemu" "windows2k25" {
  vm_name                = "windows-2025-V24h2-B26100-4652"
# Windows 2025  - Internet
  # iso_url                = 
# instanceType is u1.2xmedium 2 vCPUs and 4GB of RAM
  format                 = "qcow2"
  output_directory       = "build"
  machine_type           = "q35"
  accelerator            = "kvm"
  cpus                   = "2"
  memory                 = "4096"
  disk_size              = "102G"
  headless               = "true"
  disk_compression       = "true"
  firmware                = "uefi"
  efi_boot                =  true
  efi_firmware_code       = "/usr/share/OVMF/OVMF_CODE.fd"
  efi_firmware_vars       = "/home/jenkins-agent/ovmf/OVMF_VARS.fd"
  # qemuargs                = [["-drive", "file=build/{{ .Name }},if=virtio,cache=writeback,discard=ignore,format=qcow2,index=1"]]
  # vtpm                    = true

qemuargs = [
  ["-drive", "file=/home/jenkins-agent/.cache/packer/45173890bb9e0fc063f71cfb6d5ec40a0210e2d9.iso,media=cdrom,index=4"],
  ["-drive", "if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd"],
  ["-drive", "if=pflash,format=raw,file=/home/jenkins-agent/ovmf/OVMF_VARS.fd"],
  ["-boot", "order=d"]
]

  shutdown_command     = "c:\\windows\\system32\\sysprep\\sysprep.exe /generalize /oobe /shutdown /unattend:a:\\unattend.xml"


  #host_port_min = 5985
  #host_port_max = 5985
  skip_nat_mapping       = true

  communicator           = "winrm"
  winrm_username         = "Administrator"
  winrm_password         = "${var.winrm_admin_password}"


  net_device             = "e1000"
  # net_device             = "virtio-net" # didn't work

  disk_interface         = "ide"
  # disk_interface         = "scsi" # didn't work
  # disk_interface         = "sata" # didn't work
  # disk_interface         = "virtio"  # didn't work
  # disk_interface         = "virtio-scsi" # didn't work

  cd_files               =  ["./virtio_drivers/virtio-win-0.1.271-drivers.iso"]
  
  floppy_files          = ["../answer-files/autounattend.xml", "../answer-files/unattend.xml", "../scripts/network-configs.ps1","../scripts/post-config.ps1"]

boot_command = [
  "fs1://bootmgr.efi",
  "<wait60>"
    ]

I’m now getting this, I cannot even run bootmgr.efi file

any idea what is going on ? is there a known issue between Packer and Windows server 2025 UEFI mode ?