Home News Consolidating snapshots -VMware KB Article 1007849

Consolidating snapshots -VMware KB Article 1007849

by Roger Lund

A new KB Article : Consolidating snapshots -VMware KB Article 1007849

This can cause problems, so I quoted the whole KB, this is all from VMware.com and none of this was written by my self.


Symptoms

When powering on a virtual machine, the following error message is displayed:

The parent virtual disk has been modified since the child was created

Resolution

This error can occur under the following circumstances:
  • The base disk of the virtual machine has been changed
  • Running out of space on the LUN that contains the snapshot
  • Virtual machine suffers a blue screen exception when a snapshot is taken
For more details about snapshots and missing header files, see Cannot power on a virtual machine because the virtual disk cannot be opened (1004232).
Before implementing the solution, ensure:
  • You know the file names of all virtual disks associated with the virtual machine. Use the following command and record the output:

    # grep -i filename /vmfs/volumes/old_datastore/vmdir/*.vmx | grep -i vmdk

  • That there is enough space on the target datastore to receive the cloned virtual disks. Use the following command to assess how much space is needed:

    # ls -lah /vmfs/volumes/old_datastore/vmdir/*flat.vmdk

    Note: This example assumes that all of the virtual disks are contained in the directory with the virtual machine configuration file (.vmx).

  • A complete snapshot chain with matching CIDs and Parent CIDs (obtained from step 2 in the procedure).
  • The virtual machine is in a powered off state.
  • There is enough time to commit the snapshots. This procedure can take an extended amount of time depending on the size of the delta files.
To match the CID of the snapshot to the base disk:
  1. Find out what disks the virtual machine is using.

    Log in to the ESX host and navigate to the directory that contains the virtual machine. Run the following command to identify which virtual disk files are being used:

    # grep -i filename *.vmx

    The output appears similar to:

    scsi0:0.fileName = “vm-000002.vmdk”
    scsi0:1.fileName = “vm_1-000002.vmdk”

    This virtual machine has two virtual disks.

  2. Check the CID of the base disks and compare them to the snapshots to see if they match.

    Run the following command to obtain the information about the virtual disk:



    # cat vm_1-000002.vmdk

    The output appears similar to:

    CID=929c1b7d
    parentCID=20d215cd
    createType=”vmfsSparse”
    parentFileNameHint=”vm_1-000001.vmdk”

    This indicates that the file vm_1-000001.vmdk has the CID of 20d215cd.

    Do this for each file in the snapshot chain until you get to the base disk.

  3. Clone the virtual disk to a new base disk.

    To clone the virtual disk:

    1. Run the vmkfstools -i command to copy out and consolidate the snapshots. This requires enough space for the base disk. The command ls -l *-flat.vmdk gives the size of each base disk in the current directory.
    2. Create a directory on a the target datastore if you are not cloning to the current directory:

      # mkdir /vmfs/volumes/new_datastore/recover

    3. Run the vmkfstools -i command to clone out the last vmdk delta disk pointer VMDK:

      # vmkfstools -i /vmfs/volumes/old_datastore/vmdir/vm_1-000002.vmdk /vmfs/volumes/new_datastore/recover/vm_1.vmdk

      The output appears similar to:

      Destination disk format: VMFS thick
      Cloning disk ‘/vmfs/volumes/old_datastore/vmdir/vm_1-000002.vmdk’…
      Clone: 100% done.


      Note: If the above process does not work, choose the next snapshot up the tree as the one you are on (or one of the higher ones) is corrupt.

    4. Detach the disk from the virtual machine using the VI Client.
    5. Attach the new disk, /vmfs/volumes/new_datastore/recover/vm-disk2.vmdk to the virtual machine.
    6. Power up the virtual machine and ensure data integrity (Event Viewer, SQL, E-mail, etc).

  4. Delete the base disk and only it’s snapshot disks.

    # grep -A2 parentFile vm_1-000002.vmdk | grep -v “#”

    The output appears similar to:

    parentFileNameHint=”vm_1-000001.vmdk”
    RW 41943040 VMFSSPARSE “vm_1-000002-delta.vmdk”

    This indicates that the pointer vm_1-000002.vmdk points to vm_1-000002-delta.vmdk and is using vm_1-000001.vmdk as it’s parent disk.

    You may run the same command on the parent pointer to determine what files it uses, until you locate them all.

    # rm /vmfs/volumes/old_datastore/vmdir/vm_1-000002.vmdk
    # rm /vmfs/volumes/old_datastore/vmdir/vm_1-000002-delta.vmdk
    # rm /vmfs/volumes/old_datastore/vmdir/vm_1-000001.vmdk
    # rm /vmfs/volumes/old_datastore/vmdir/vm_1-000001-delta.vmdk
    # rm /vmfs/volumes/old_datastore/vmdir/vm_1.vmdk
    # rm /vmfs/volumes/old_datastore/vmdir/vm_1-flat.vmdk

    Note: If you are going to use rm with a wildcard, echo the command first. This allows you to see which files are being targeted for erase.

    # echo rm *.vmdk

  5. Move the VMDKs back to the original location and re-associate the virtual machine with the new disks.

    To move the VMDKs back to the original location:

    1. Run the following command to clone the disk back to the original data store.

      # vmkfstools -i /vmfs/volumes/new_datastore/recover/vm_1.vmdk /vmfs/volumes/old_datastore/vmdir/vm_1.vmdk

    2. Detach the recovered disk from the virtual machine using the VI Client
    3. Attach the new disk in the original location, /vmfs/volumes/old_datastore/vmdir/vm-disk2.vmdk to the virtual machine.
    4. Power up the virtual machine and ensure data integrity (Event Viewer, SQL, E-mail, etc).

  6. Clean up the snapshot database.

    Rename the .vmsd file, remove the virtual machine from inventory, and re-add the virtual machine to clear the snapshot database.

    # mv vm.vmsd vm.oldvmsd

Full KB at VMware.com
http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=1007849&sliceId=1&docTypeID=DT_KB_1_1&dialogID=10302840&stateId=1%200%2010310298

You may also like