Commit a VMware snapshot from ESXi as it doesn’t appear in vCenter or command line tools

First of all we get the ID of our VM:

# vim-cmd vmsvc/getallvms

Check his snapshots:

# vim-cmd vmsvc/snapshot.get <vmid>
Get Snapshot:

We can see that we don’t have any snapshot but that’s not true:

# ls -l *vmdk
-rw-------    1 root     root       6554112 Oct 30 20:55 vm-000001-ctk.vmdk
-rw-------    1 root     root   16559525888 Oct 30 20:55 vm-000001-delta.vmdk
-rw-------    1 root     root           393 Apr 21  2014 vm-000001.vmdk
-rw-------    1 root     root       6554112 Apr  3  2014 vm-ctk.vmdk
-rw-------    1 root     root  214748364800 Apr  3  2014 vm-flat.vmdk
-rw-------    1 root     root           585 Apr  2  2014 vm.vmdk

In order to fix it, first of all shutdown the VM as it can’t be fixed online:

# vim-cmd vmsvc/power.shutdown <vmid>

And we commit the snapshot manually from command line to a new disk (it can take some time):

# vmkfstools -i vm-000001.vmdk new.vmdk
Destination disk format: VMFS zeroedthick
Cloning disk 'vm-000001.vmdk'...
Clone: 100% done.

If the task was successfully now we overwrite our old files and delete the delta disk (I suppose that you have backups just in case something goes south):

# mv new-ctk.vmdk vm-ctk.vmdk
# mv new-flat.vmdk vm-flat.vmdk
# mv new.vmdk vm.vmdk
# rm *000001*

And finally edit your vmx/vmdk file to reflect this changes:

# grep vmdk *vmx
scsi0:0.fileName = "vm.vmdk"
# grep vmdk vm.vmdk 
RW 419430400 VMFS "vm-flat.vmdk"

And if you powerup your VM everything should be back to normal!

If you have more than one snapshot this might be handy:


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.