Verifying a Snapshot Chain and Cloning a Virtual Disk from Snapshots
search cancel

Verifying a Snapshot Chain and Cloning a Virtual Disk from Snapshots

book

Article ID: 309366

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This document is to provide the steps necessary to manually clone a virtual disk with snapshots to a new virtual disk instead of attempting to consolidate the existing snapshots to the original base disk. Some instances may create snapshots of a virtual disk that is not visible within snapshot manager of the vSphere Client and user wants to retain the original disks while creating a cloned copy of a virtual disk.

Environment

VMware vSphere ESXi


Resolution

Verify the snapshot disk that the Virtual Machine is currently running on:

  • From vSphere Client,
    1. Right-click on the VM within the vSphere client and select "Edit Settings"
    2. Click on the hard disk(s) to identify the current disk file and datastore. (Note: The datastore name will appear in brackets)
      If the virtual disk is running on snapshots, the VMDK should appear with the virtual disk name with a 6 digit number with leading zeros. This is the VMDK descriptor filename. (Example: "VM1-000001.vmdk")
  • From console,
    1. Change directory to the virtual machine configuration file folder
      cd /vmfs/volumes/Datastore/VMdirectory
    2. Run this command to list the virtual disks (with latest snapshots) associated with this machine
      grep vmdk *.vmx

Verify the Consistency of the Snapshot Chain

  1. Locate the host in which the virtual machine is currently registered by opening the "Summary" tab of the VM within the vSphere client
    • Select the virtual machine within the vSphere client
    • Click the Summary tab
    • Locate the Host under the General Pane
  2. Establish an SSH session into that host. 
  3. Change to the directory in which the virtual disk is located
    cd /vmfs/volumes/Datastore/VMdirectory
  4. Verify the consistency of the snapshot chain for the VMDK by typing this command (Note: ensure the SSH session being used is on the ESXi host that the virtual machine is currently running on to avoid lock errors)

    vmkfstools -qv10 <VMDKDESCRIPTORFILE>

    The output should show that show the delta disks are successfully opened and closed if the Chain is consistent.

    Example:
    /vmfs/volumes/########-########-####-############/<server name> # vmkfstools -qv10 <server name>-000001.vmdk
    DISKLIB-VMFS : "./<server name>-000001-delta.vmdk" : open successful (23) size = 86016, hd = 0. Type 8
    DISKLIB-VMFS : "/vmfs/volumes/########-########-####-############/<server name>/<server name>-flat.vmdk" : open successful (23) size = 42949672960, hd = 0. Type 3
    <server name>-000001.vmdk is not an rdm
    DISKLIB-VMFS : "./<server name>-000001-delta.vmdk" : closed.
    DISKLIB-VMFS : "/vmfs/volumes/########-########-####-############/<server name>/<server name>-flat.vmdk" : closed.
    AIOMGR-S : stat o=2 r=6 w=0 i=0 br=98304 bw=0

    If the chain is broken, the output will return results like this -

    /vmfs/volumes/########-########-####-############/<server name> # vmkfstools -qv10 <server name>-000001.vmdk
    ...
    DISKLIB-LINK : DiskLinkIsAttachPossible: Content ID mismatch (parentCID fffffff3 != fffffffe) <server name>-000001.vmdk /vmfs/volumes/########-########-####-############/<server name>/<server name>.vmdk.
    DISKLIB-CHAIN : "/vmfs/volumes/########-########-####-############/<server name>/<server name>.vmdk" : failed to open (The parent virtual disk has been modified since the child was created. The content ID of the parent virtual disk does not match the corresponding parent content ID in the child).
    ...
    Failed to open '<server name>-000001.vmdk' : The parent virtual disk has been modified since the child was created. The content ID of the parent virtual disk does not match the corresponding parent content ID in the child (18).


Clone the Snapshot Chain to a New Virtual Disk

  1. Enter 'ls' command to ensure the current directory and the proper directory in which the VMDK resides are the same.
  2. Enter the following command to clone the virtual disk :
    vmkfstools -i <source file vmdk>.vmdk /vmfs/volumes/DestinationDatastore/<NEW VMDK FILE>.vmdk

    Example:
    vmkfstools -i <server name>-000001.vmdk /vmfs/volumes/NewDatastore/<server name>-NewDisk.vmdk

    By default, the new disk will clone as a thick provisioned disk. To clone a new thin provisioned disk, use the following command:
    vmkfstools -i <source file vmdk>.vmdk <DESTINATION VMDK FILE>.vmdk -d thin
Attach new Virtual Disk to an existing virtual machine to verify data
  1. Ensure the virtual machine is powered off.
  2. Within the vSphere client, right-click the virtual machine in question and select "Edit Settings"
  3. Click "Add" and select "Hard Disk" and click "Next"
  4. Select the option "Use an existing virtual disk" and click "Next"
  5. Navigate to location of the new VMDK file by clicking "Browse"
  6. Select the new VMDK file that was created from clone and click "OK" and "Next" in the Add Hardware window
  7. Verify the settings applied and click "Finish"
  8. Click "OK" in the Virtual Machine Properties window
  9. Power on the virtual machine. It should now be utilizing the cloned disk.
  10. Repeat this process for any additional virtual disks that need to be cloned.



Additional Information

  • In ESXi 5.x, there is -e option available for vmkfstools to verify snapshot chain. Running vmkfstools -e <VMDKDESCRIPTORFILE> returns "Disk chain is consistent" if the chain is good.

    Note:
    the virtual machine must be powered off to run -e option, otherwise it will return the following error -
    Failed to lock the file (16392)Disk chain is not consistent : Failed to lock the file (16392)


Impact/Risks:

  • This process creates a copy of virtual disks and can consume larges amount of storage space. Ensure that there is enough space on the destination datastore before proceeding.
  • Verify all files names used to ensure that each file name is unique.