Convert Disks for XCP ng - tgs-jbraun/JumpCloud-Seeding GitHub Wiki
convert-vhdx-to-vhd.ps1 batch converts Hyper-V VHDX disks to the dynamic VHDs that XCP-ng imports. It follows the XCP-ng migration guide and leaves the VHDX files unchanged. Run it on the Hyper-V host in Windows PowerShell 5.1, as administrator.
-
Remove the Hyper-V integration tools from each guest, then shut the VMs down.
-
Convert the disks of whole VMs, or of every VHDX in a folder:
.\Tools\convert-vhdx-to-vhd.ps1 -VMName DC01, WIN11-01 -Destination C:\XCP-ng .\Tools\convert-vhdx-to-vhd.ps1 -Path C:\ProgramData\Microsoft\Windows\Hyper-V -Destination C:\XCP-ng
-
In Xen Orchestra, open Import > Disk, pick the storage repository and upload each VHD.
-
Create a VM from a template without disks.
-
Attach the imported disk to the VM, then start it.
-
Install the XCP-ng guest tools in the VM.
The script skips a disk, and says why, if the disk:
- is larger than 2040 GiB, the VHD format's limit
- has 4096-byte logical sectors, which VHD doesn't support
- is a checkpoint disk. Delete the VM's checkpoints first, so Hyper-V merges them.
- belongs to a running VM
It doesn't replace an existing VHD unless you add -Force.
To copy the VHDs into a file-based storage repository instead of uploading them, add -XcpNaming. The script then names each VHD <UUID>.vhd, the only name XCP-ng accepts there. mapping.csv records which VHDX each UUID came from. Rescan the storage repository after copying.