Friday, February 17, 2012

How to use the vhd-util tool in xenserver




I have always found that the vdi chain in xenserver is one area where there is always some misunderstanding on how it all hangs together so I thought I would blog about how the vdi chains work and the vhd files make up the vdi chain. When running blocked based storage in XenServer, it isn't easy to see the underlying files and to do so you have to use the vhd-util tool. I have put together a guide which helps how you can see what vhd files make up the vdi chain.
 First of all, run vgs to display the volume groups, look for the the iscsi volume group and note down the name

VG_XenStorage-7ec18595-0bf0-859a-1e85-7e19721dad84   1  51   0 wz--n- 799.99G 495.84G

Here are some vhd-util scan options you can use.

usage: [OPTIONS] FILES

options: [-m match filter] [-f fast] [-c continue on failure] [-l LVM volume] [-p pretty print] [-a scan parents] [-v verbose] [-h help]

A typical command would be.

vhd-util scan -m "VHD-*" -f -c -l VG_XenStorage-7ec18595-0bf0-859a-1e85-7e19721dad84 -p –v

And the output would be this:

[root@xenserver ~]# vhd-util scan -m "VHD-*" -f -c -l VG_XenStorage-7ec18595-0bf0-859a-1e85-7e19721dad84 -p –v

vhd=VHD-79d0aca7-eda7-4d73-9238-c3b5c9378aa7 capacity=26843545600 size=4630511616 hidden=1 parent=none
   vhd=VHD-691d986e-e84a-4ab4-9672-b6f9b3148cab capacity=26843545600 size=26902265856 hidden=0 parent=VHD-79d0aca7-eda7-4d73-9238-c3b5c9378aa7
   vhd=VHD-838154db-db5c-42b7-8ec3-2ebb31f73683 capacity=26843545600 size=8388608 hidden=0 parent=VHD-79d0aca7-eda7-4d73-9238-c3b5c9378aa7
vhd=VHD-80c4d84c-8aea-4391-9d31-fcc2be388ce6 capacity=21474836480 size=4626317312 hidden=1 parent=none
   vhd=VHD-0eaa0588-3668-4697-956d-bd6e98478585 capacity=21474836480 size=8388608 hidden=0 parent=VHD-80c4d84c-8aea-4391-9d31-fcc2be388ce6
   vhd=VHD-240a20e8-0d70-4b4a-88c1-e4b2a6e138e7 capacity=21474836480 size=21525168128 hidden=0 parent=VHD-80c4d84c-8aea-4391-9d31-fcc2be388ce6
vhd=VHD-a5d73baa-1eb6-4fe6-a2e9-32ddcf14555a capacity=2147483648 size=2101346304 hidden=1 parent=none
   vhd=VHD-87e8553e-340d-4269-8401-f2b4be874b62 capacity=2147483648 size=8388608 hidden=0 parent=VHD-a5d73baa-1eb6-4fe6-a2e9-32ddcf14555a
vhd=VHD-1b10a183-ef8d-4c53-a031-b9aeeb38e0be capacity=10737418240 size=10766778368 hidden=0 parent=nonevhd=VHD-2e45811f-c3a1-48bf-b6b0-0d0fb671da8e capacity=5368709120 size=5385486336 hidden=0 parent=none
vhd=VHD-6fe32f92-bc88-4f98-a4e1-47bf04894ce8 capacity=21474836480 size=21525168128 hidden=0 parent=none
vhd=VHD-8336df72-992d-4a52-a5e3-4a776f1f86f8 capacity=5368709120 size=5385486336 hidden=0 parent=none

Typically, the chain consists of a base-copy, where VHD has the attributes hidden=1 parent=none. Subsequent VHD chain’s have the following attributes - hidden=0 parent=<VHD-UUID>. The following is a good example of a two child chain, which is actually the domain router in Cloudstack

vhd=VHD-ff1c907a-d75d-444e-af85-735121fb9794 capacity=2097152000 size=2101346304 hidden=1 parent=none
   vhd=VHD-14175cb0-35f5-4b45-b686-7d34348283b4 capacity=2097152000 size=2109734912 hidden=0 parent=VHD-ff1c907a-d75d-444e-af85-735121fb9794

It starts getting tricky when snapshots get involved. There is a coalescing process which runs and changes the chains – good article on how snapshots work http://support.citrix.com/servlet/KbServlet/download/21626-102-671572/XenServer_-_Understanding_Snapshots_(v1.1).pdf

Relating this to how Cloudstack typically works, we should only see a maximum chain on 2 childs. Each base-copy relates to a unique template. Chains are then created from the base-copy. Multiple templates will mean multiple base-copies. A base-copy which stems from a cloudstack template can exists on many SRs across many pools. If you were taking multiple snapshots using XenCenter, you would have multiple VHD chains which would reflect the snapshot structure.

Hope that helps understanding VHD chains. It is handy to see how the guts of the disk structure hangs together as sometimes you need to troubleshoot broken vdi health, I dare I say the dreaded error 22.

9 comments:

  1. For restoring or recovering deleted VHD file, you can use third party VHD data recovery software. Due to carelessness I removed some necessary data of VHD file. Then I used this tool and found it is all in one VHD recovery software. You can grab this easy solution from here: - http://www.filesrecoverytools.com/vhd-data-recovery.html


    ReplyDelete
  2. One more Virtual Machine Data Recovery tool which can fix both FAT and NTFS file systems on virtual hard disk (VHD) created using Microsoft's virtualization solution. This software handles all issues related to accessibility or use of Windows Hyper-V VHD files easily.

    Read more: http://www.softmagnat.com/virtual-machine-data-recovery.html



    ReplyDelete
  3. I would like to suggest VHD Data Recovery software which provides effective and quick solution to recover data from corrupt VHD, it provides free trial version to recover lost VHD files.It can deeply scan corrupted Virtual partition whether it is FAT based or NTFS and then repair fixed & dynamic vhd file corruption/damage issues with no harm.

    ReplyDelete
  4. Here I am going to share VHD Recovery Software recommendation that will help you to make all inaccessible VHD files again in used form. To know how fix corrupt issue of VHD file visit: http://www.vdiskrecovery.com/

    ReplyDelete
  5. Use VHD Recovery software which is an ultimate utility to get back deleted or lost data from Microsoft (VHD), Oracle (VDI) and VMware (VMDK) image files. It allows recovery of all the data like database, Office files, audio, image, videos, archive and backup files and other data. It is supported by Windows 10,8,7, Windows Server 2008 R2, 2012 R2 and Hyper-V Server.

    Visit here: http://www.vhd.recoverydeletedfiles.com/

    ReplyDelete
  6. It's about citrix xenserver not for microsoft,VMware and Oracle vm.

    ReplyDelete
  7. First see that what the author want to say.

    ReplyDelete
  8. VHD file Recovery software to repair and restore corrupted or damaged VHD files data without any data loss. This tool scans the FAT and NTFS file systems of the virtual hard disk and fix all types errors and issues, then recover corrupt, damaged or lost VHD files. It supports VHD files created using Windows Server 2008 R2 and 2012 R2, Windows 8.1, Windows 8, Windows 7 and Hyper- V server. See more information at: https://www.mozesoft.com/datarecovery/vhd-data-recovery.html

    ReplyDelete
  9. VHD recovery tool that can recover VHD files completely after an event of corruption or data loss. It scans FAT and NTFS files systems of the virtual hard disk and recovers the corrupt, damaged or lost files. See more information at: https://softcart.wordpress.com/vhd-recovery-software/

    ReplyDelete