VM creation on hyper-v using golden image fails

Hi Team,

We’ve a hyper-v node added as hyper-v cloud in the Morpheus, Able to deploy VM into it using images from Morpheus marketplace.

We created a golden image for windows server 2022 in the same hyper-v node, Created 1 2022 VM and followed steps provided in Morpheus documentation for golden image creation. Imported VHDx of that VM to Morpheus and created node type,instance types and layout. When we try provision the VM using that golden image to hyper-v node, Provisioning fails with generic message “Your Instance Test-006 had a failure occur during provisioning”.

On Hyper-v node I do see a VM getting created which is unable to find a boot media/source


Any input is greatly appreciated !

Suresh Thakur

Are you stating you imported the vhdx manually? Or are you saying on a sync, you found it under Library > Virtual Images?

Yes, I imported it manually by uploading it to local storage bucket from library > virtual images.

Are you using packer, or are you modifying the VM in hyper-v, shutting down and exporting the vhdx?

After following steps in VM i’m using sysprep ( sysprep\sysprep.exe /generalize /shutdown /oobe) to generalize and shurdown the VM, Once VM is off then i upload the VHDx file to Morpheus.

Our process is to use packer, with use_fixed_vhd_format = "true" and skip_compaction = "true" with a Gen1 vhd file. That’s what I know works.

Can you DM me a log of you trying to deploy this? There might be a clue in there for me, but I haven’t dug into using Gen2 vhdx disk images in Hyper-V, myself.

I tried same steps with Gen1 VM’s as well but facing the same challenge, If convenient please share steps to use Packer for this process.

I’m not sure if any of this is different with Windows.

I only have a process for building images with packer and the config is pretty simple:

source "hyperv-iso" "ubuntu" {
    iso_url = "${var.iso_url}"
    iso_checksum = "${var.iso_checksum}"
    shutdown_command = "${var.shutdown_command}"
    disk_size = "${var.disk_size}"
    use_fixed_vhd_format = "true"
    skip_compaction = "true"
    headless = "true"
    memory = "${var.memory}"
    http_directory = "${var.http_directory}"
    ssh_username = "${var.ssh_username}"
    ssh_password = "${var.ssh_password}"
    ssh_timeout = "${var.ssh_wait_timeout}"
    vm_name = "${local.vm_name}"
    boot_command = ["c<wait>linux /casper/vmlinuz --- autoinstall ds=\"nocloud-net;seedfrom=http://{{.HTTPIP}}:{{.HTTPPort}}/u22_cloudinit_hyperv/\"<enter><wait>initrd /casper/initrd<enter><wait>boot<enter>"]
    output_directory = "${var.output_directory}"

build {
    sources = [
  provisioner "file" {
    source = "../supportfiles/os_detect.sh"
    destination = "/tmp/os_detect.sh"
  provisioner "shell" {
    script = "../supportfiles/ubuntu_setup.sh"
  provisioner "shell" {
    script = "../supportfiles/ubuntu_cleanup.sh"
  post-processor "shell-local" {
    tempfile_extension = ".ps1"
    execute_command = ["powershell.exe", "{{.Vars}}  {{.Script}}"]
    env_var_format = "$env:%s=\"%s\"; "
    inline = [
        "cd '${var.output_directory}\\Virtual Hard Disks'",
        "tar cvzf ..\\${local.vm_name}.vhd.tar.gz ${local.vm_name}.vhd",
        "cd ..",
        "del -Recurse 'Virtual Hard Disks'",
        "del -Recurse 'Virtual Machines'"