I was recently working with Doug Brown (@douglasabrown, DABCC) and Shane Kleinert (@shanekleinert, CitrixIRC) on converting a VMware VMDK to VHD for use with XenClient. Using XenConvert to convert the VMDK to VHD completed without errors but when following Citrix Knowledgebase Article CTX127075 – Attempting to use a Virtual Hard Disk on XenClient 1.0 Created Using XenConvert or From a Pre-Release XenClient System Fails with Error Code 199 and using the vhd-copy script, the size of VHD file didn’t look right. In this blog post I am going to go over the process of converting a VMDK to VHD for use with XenClient.
Previous versions of XenClient allowed you to use an existing VHD file with a virtual machine on XenClient. With the release of XenClient 1.0 a disk encryption facility with some additional virtual hard disk headers and hard disk checking was added. When a virtual machine is started in XenClient 1.0, XenClient checks for the additional hard disk options. If the additional hard disk options are present, then the virtual machine fails to start with Error Code 1099.
I have used XenConvert to convert physical machines and have also used VHD files from XenServer successfully with XenClient. Until recently I have not tried converting a VMware VMDK to VHD format using XenConvert for use with XenClient. I thought the process would be pretty straight forward and it was until running the vhd-copy script from Citrix Knowledgebase Article CTX127075 – Attempting to use a Virtual Hard Disk on XenClient 1.0 Created Using XenConvert or From a Pre-Release XenClient System Fails with Error Code 199. The size of the target VHD file from the vhd-copy script was a fraction of the size compared to the source VHD file.
Using XenConvert to convert from VMDK to VHD format was a successful conversion without errors.
The converted VHD file was then copied over to the XenClient machine using WinSCP. After the VHD file and vhd-copy script were copied over to the /storage/disks directory on the XenClient machine, the vhd-copy script was executed by making an SSH connection to the XenClient machine. You can also do it from the XenClient machine shell terminal by pressing CTRL+SHIFT+T keys. The vhd-copy command used was ./vhd-copy –src WinXP.vhd –dest WinXPFixed.vhd. Notice successful completion of the vhd-copy script and the size difference in the screenshot below for the WinXP.vhd and WinXPFixed.vhd files.
After running XenConvert again to convert from VMDK to VHD format and running the vhd-copy script again, we got the same results. WinImage was also used to convert the VMDK to VHD but errors were received when running the vhd-copy script. In the end VMDK to VHD Converter was used to convert from VMDK to VHD format. The converted VHD file was then copied to the XenClient machine using WinSCP. After the VHD file and vhd-copy script were copied over to the /storage/disks directory on the XenClient machine, the vhd-copy script was executed by making an SSH connection to the XenClient machine. You can also do it from the XenClient machine shell terminal by pressing CTRL+SHIFT+t keys. The vhd-copy command used was ./vhd-copy –src WinXPPro.vhd –dest WinXPProFixed.vhd. Notice successful completion of the vhd-copy script and now the size of VHD files are almost the same size in the screenshot below for the WinXPPro.vhd and WinXPProFixed.vhd files.
Now that the VHD file is properly encrypted for use with XenClient 1.0 it can be used with a virtual machine on XenClient. To use the VHD file with a XenClient virtual machine do the following:
- Create a virtual machine but do not start it.
- Connect to the XenClient machine by using Putty or open a shell terminal on XenClient by pressing CTRL+SHIFT+t keys.
- Change directory to /storage/disks.
- Find the VHD file created by the virtual machine created in step 1 and change the name from guidofvm.vhd to guidofvhd.orig.
- Change the name of the converted virtual machine VHD file from convertedvm.vhd (Example from above WinXPProFixed.vhd) to guidofvm.vhd.
- Start the virtual machine.
You should now have a virtual machine running on XenClient that was converted from a VMDK to VHD. Big thanks to Doug Brown and Shane Kleinert for the team effort on this one.
If you have found this article interesting or if you have any other insights, please feel free to contact me via email.