Recover XenServer VHD Volumes

So you blew up your CloudStack installation and all you have is a chain of XenServer VHD files on your primary storage.

The recovery process would involve creating a coalesced volume from the available VHD chain files. The steps outlined in CloudStack’s CreateVolumeFromSnapshotCommand API says…

* Given the UUID of a backed up snapshot VHD file on the secondary storage, the execute of this command does
* 1) Get the parent chain of this VHD all the way up to the root, say VHDList
* 2) Copy all the files in the VHDlist to some temp location
* 3) Coalesce all the VHDs to one VHD which contains all the data of the volume. This invokes the DeletePreviousBackupCommand for each VHD
* 4) Rename the UUID of this VHD
* 5) Move this VHD to primary storage

Comment numbered (1), (2) and (3) are what we are interested in. So using vhd-util, you can coalesce the chain VHDs as below:

# vhd-util scan -f -m'*.vhd' -p
vhd=c15d6628-0109-4e7a-9b45-28ed4e2fbbed.vhd capacity=21474836480 size=1155727872 hidden=1 parent=none
   vhd=c32d7e83-6c1e-4609-8ff3-a44ff50e1af3.vhd capacity=21474836480 size=1529294848 hidden=0 parent=c15d6628-0109-4e7a-9b45-28ed4e2fbbed.vhd
# vhd-util coalesce -n c32d7e83-6c1e-4609-8ff3-a44ff50e1af3.vhd 

This would be a manual step for each VHD chain you have. Once the VHD is coalesced, import the parent as a regular XenServer VHD template and manually set the OS Type. Some trial and error might be required to get the OS type right.

Finally, launch a new instance from the imported template.


OpenStack – XenServer – type Image to Volume (Citrix Blog)

Shanker Balan

Shanker Balan is a devops and infrastructure freelancer with over 14 years of industry experience in large scale Internet systems. He is available for both short term and long term projects on contract. Please use the Contact Form for any enquiry.

More Posts - Website

Follow Me:

3 Replies to “Recover XenServer VHD Volumes”

  1. Hi Shanker,

    I have a setup with CS 4.3 & XS 6.2. I want to bring out few VMs from Cloudstack environment to standalone Xen Server. But the standalone Xen server not able to recognize the VHDs imported from Xen Servers under cloudstack. Looks like VHD-UTIL has encrypted the VHD files. I have tried the steps provided in your blog but still not able to fix. Find below the errors.

    [root@xenserver-1 3596eda9-e33f-7adb-383f-3cffe483ed38]# vhd-util scan -f -m ‘ed2077c2-b65e-45a6-9efe-773e848c7729.vhd’ -p
    vhd=ed2077c2-b65e-45a6-9efe-773e848c7729.vhd capacity=21474836480 size=3114091008 hidden=0 parent=none

    [root@xenserver-1 3596eda9-e33f-7adb-383f-3cffe483ed38]# vhd-util coalesce -n ed2077c2-b65e-45a6-9efe-773e848c7729.vhd
    error finding ed2077c2-b65e-45a6-9efe-773e848c7729.vhd parent: -22
    error coalescing: -22

    In this case I have taken VM Template vhd, which is created from ISO. So “error coalescing: -22” should not appear.

    Pl. let me know if you have faced any issue like this and how do you resolved?

    Thanks in advance

  2. Hi Asit,

    In my experience, an export of data and root volumes form the CloudStack UI is not encrypted. In fact, I use this facility to export templates between different cloudstack clouds.

  3. Hi Shanker,
    Thanks for this quick response. I’m agree with you. There is no issue during VHD templates exported between different cloudstack clouds. The problem is arising when I’m exporting the VHD templates from cloudstack and trying to start the VM (VHD) in a XenServer which is not under the management of cloudstack.

Leave a Reply