Thursday, October 11, 2012

Consolidate a disk with deltas when the virtual machine claims that there are no snapshots in VMware esx 4.x

I’ve recently have and issue with a virtual machine that had not been able to consolidate the deltas in all the disks after a snapshot remove. So I had a virtual machine without snapshots but some disks with deltas.

image

In esx 4.x you can clone an individual virtual machine disk with or without deltas (Here you can view the KB document that explains how), but if your base disk is large this can take a very long time, and you will need enough free space to clone the disk.

So I’m trying to consolidate the disk in the same way this task is done when you remove a snapshot, these are the steps:

 

  • Create a new virtual machine of any type with a single disk, this disk must be the base disk without the deltas.image
  • If your deltas are in the same folder than the base disk rename them to avoid errors.
   1: vmkfstools -E COPIAS-000002.vmdk DELTA-000002.vmdk
   2: vmkfstools -E COPIAS-000001.vmdk DELTA-000001.vmdk


  • Unregister the newly created virtual machine and move the .vmx file to the folder where is your disks and his deltas.



   1: mv New\ Virtual\ Machine/New\ Virtual\ Machine.vmx COPIAS


image



  • Register the vm again.


   1: vmware-cmd -s register <full path to virtual machine>\<virtual machine name>.vmx


  • Take as much snapshots in your new virtual machine as deltas you have for your base disk, this will create new deltas with the standard name.image
  • Replace the newly created delta with you first saved (and previously renamed) delta disk.


   1: rm -f COPIAS-000001*
   2: rm -f COPIAS-000002*
   3: vmkfstools -E DELTA-000001.vmdk COPIAS-000001.vmdk
   4: vmkfstools -E DELTA-000002.vmdk COPIAS-000002.vmdk


image



  • Once the snapshots deletion has finished you can remove from the inventory the virtual machine created for this purpose and his .vmx file.

No comments:

Post a Comment