I will show the procedure by cloning a snapshot of a vm since this is a little more tricky than cloning just a single vm.
First let’s make a snapshot of my Xp3 vm. Right click the vm and make a snapshot, let’s call it “mySnapshot”. Of course you don’t need to do this if you just want to clone a single vm. After that, shutdown the vm otherwise the files will be locked.
Now enable the ssh service on your ESXi by going to the configuration tab and the security policy option. Just start it for the moment, you don’t need to set it to start automatically. Use a ssh client like putty and connect to the hypervisor. Browse the folder under /vmfs/volumes path. It should look like this
in my case I have two datastores and my Xp3 vm is in datastore2, so let’s get into it.
As you can see now, there are more than one vmdk disk files, the flat vmdk, the delta vmdk and the vmdk descriptor file (the Xp3-000001.vmdk file in our example), along with the memory snapshot and various control and log files. What we should use here as a source file is the descriptor file that points to our snapshot. If you didn’t have a snapshot, the source file would be the vmdk descriptor file of your vm, Xp3.vmdk.
Now, what I need to do is clone my Xp3 snapshot to a new Xp4 vm. First create the destination folder in datastore2 folder and type in the following commands
and clone the disk file
vmkfstools -i /vmfs/volumes/datastore2/Xp3/Xp3-000001.vmdk /vmfs/volumes/datastore2/Xp4/Xp4.vmdk -d thin
if it was a single vm without a snapshot, you should run
vmkfstools -i /vmfs/volumes/datastore2/Xp3/Xp3.vmdk /vmfs/volumes/datastore2/Xp4/Xp4.vmdk -d thin
if you list the files in the destination folder you will see the new flat file and the descriptor file.
The actual syntax of vmkfstools command is
vmkfstools -i source_path destination_path -d disk_format -a adapter_type
man vmkfstools for more on this command
Finally create a new vm and force the use of an existing disk file.
You are ready to power it on.
if you list the folder of the cloned vm you will see something like that
Don’t forget to use sysprep command in windows to generalize your new virtual machine.
Reference: VMWare’s website article