1. SSH to your ESXi machine
2. vmware-cmd -l ( to list
virtual machines in this host)
3. cd <virtual machine directory
name> ( to change to the vm directory )
4. ls -ltrh ( to view the contents
in this directory )
a) .VMX is the vm's own configuration file
b) xxxxx-flat.vmdk is the base disk
c) each xxxxx-flat
vmdk file has a smaller .vmdk descriptor file
d) xxxxx-0000??-delta.vmdk are snaphot files
e) each xxxxx-0000??-delta.vmdk file
has smaller .vmdk descriptor file
5. Find out
all the disks associated with the virtual machine. The disk maybe located on
different datastore
grep
–i filename myVM.VMX | grep –i vmdk
this command will show the current disk in use
6. Find out the associated VM’s and the space which
they are taking
ls –lah
*.vmdk
this should show you the myVM-flat.vmdk base disk and the associated –delta.vmdk files
7. Ensure
the virtual machine is powered off. You can check by the following command.
vmware-cmd myVM.vmx getstate
8. Check
that there is enough free space on the datastore.
vdf –h
make sure that there
is enough space on the drive.
9. Verify that the snapshot chain is intact
CID is a
hexadecimal number identifying the disk.
grep –i filename
myVM.VMX | grep –i vmdk
(get the current
snapshot filename)
10. you have to now verify
manually if the current snapshot files CID matches parent CID
less myVM-000003.vmdk | egrep
–i “cid|parentcid|vmdk” –color
verify that myVM-000003.vmdk is referencing myVM-000002.vmdk and if all
okay then goto the next step.
less myVM-000002.vmdk | egrep
–i “cid|parentcid|vmdk” –color
verify that myVM-000002.vmdk is referencing myVM-000001.vmdk and if all
okay then goto the next step.
less myVM-000001.vmdk | egrep
–i “cid|parentcid|vmdk” –color
this should reference the base disk myVM.VMDK
less myVM.VMDK | egrep –i “cid|parentcid|vmdk” –color
this is to the check the CID of the base disk.
If the CID of the base disk does not match with the parent CID in the myVM-000001.vmdk
than we have to manually edit the descriptor file of myVM-000001.vmdk to update
the parent CID value to match
Vi myVM-000001.vmdk
Change the parentCID value to match the base disk value and save the
file.
Verify that myVM-000001.vmdk file has the updated reference for the base
disk.
less myVM-000001.vmdk | egrep
–i “cid|parentcid|vmdk” –color
Once we have verified the SNAPSHOT chain we will use VMKFSTOOL –i tool to copy out and consolidate the
snapshots all in one step.
The clone operation may take an extended amount of time depending on the
number and size of the snapshot delta disks.
Create a new directory for the new consolidated VM.
Mkdir /vmfs/volumes/NewDatastore/recover
Pwd (get current directory
name)
Vmkfstools –i
myVM-000003.vmdk /vmfs/volumes/NewDatastore/recover/myVM_new.vmdk
Here we are committing all snapshots in the chain into new disk, myVM_new.vmdk
This will start the clone process.
If the vmkfstools command fails then
a) This could be the
reason of corrupt snapshot or
b) You maybe running out
of diskspace.
c) Run the vmkfstools
command with the next higher snapshot up in the chain.
Now at this point you have cloned the original vm disks into new vm into
a new datastore. Now we have to point the existing VM to point to the new VM
and new datastore.
1) Go to ESX host
2) Detach the existing
Hard Disk from VM (don’t delete it)
3) Attach the newly
created disk myVM_new.VMDK which has all snapshots consolidated into the base
disk.
4) Browse to the new
datastore and select the new VMDK file.
5) Power on the
virtual machine
Once the virtual machine powers up okay, we can go back to clear space
used by the original disks and snapshot files.
*** Thanks To Vmware For Showing Excellent Video ***
** Golden IT Rule : take good backups before doing anything **