Is it possible to import a Windows 11 Hyper-V VM to LXD?
I have tried the following steps but the LXD VM does not boot correctly.
The first boot of the imported VM stalls. Forcing a reboot, gets to Windows 11 recovery mode and from the Troubleshooting command prompt only x: is available. There appears to be no C:
Steps:
Prep the Windows 11 VM
For testing I create a new Windows 11 VM with the defaults (same as a the real VM I wish to migrate), except: Mem 3896 GB, 2 virtual processors, TPM enabled, Network adapter is bridged to an external adapter.
The virtio drivers were installed before shutting down the VM.
Export the VM
I deleted any checkpoints (so all changes were merged into the vhdx).
Exported the VM using Hyper-V manager
Copied the .vhdx to the target Linux host
(From <path of chosen folder>\<nameof VM>\ Virtual Hard disks\<name of VM>.vhdx)
Below is from the LXD host machine…
Install qemu-utils
sudo apt install qemu-utils
qemu-img –version #6.2.0
Check the vhdx
qemu-img check -r all <name>.vhdx
Generate the qcow2 image from the vhxd
qemu-img convert -p -O qcow2 <name>.vhdx <name>.qcow2
Create metadata.yaml file with the content below
architecture: x86_64
creation_date: 1691308780
properties:
description: Windows 11 Test
os: Windows
release: 11 22H2
Created a tar ball with the only the metadata file
tar -cvf metadata.yaml.at metadata.yaml
Imported the image
lxc image import metadata.yaml.tar <name>.vhdx –alias <image alias name>
Confirm the image is available
lxc image list <image alias name>
Launch the new VM from the imported image
lxc launch <image name> <instance name> –vm -c limits.cpu=2 -c limits.memory=4GiB –console=vga
Result
The VM starts to boot. It appears the Windows 11 wait spinner works for a while but then after a few seconds it just hangs and leaves the instance in a ERROR status.
lxc info <instance name> --show-log #does not show anything useful to aid diagnosis
Forcing a restart
lxc restart <instance name> --console=vga –force
the VM starts with Windows in repair mode and can selected the limited recovery options.
Selecting the Command prompt shows the recovery as drive X: and there is no C:\
Any tips or advice greatly appreciated. Thanks.