Project: Clone an existing VM and register the clone as a new VM. Using both WinSCP and Putty. You need to enable and start SSH on the host to be able to do this.
Source: Existing VM called ‘197-2012r2’. Source directory is: ‘/vmfs/volumes/datasstore0/197-2012r2/’ and source file is ‘197-2012r2.vmdk’
Clone is ‘196-2012r2’ and use a directory called: ‘/vmfs/volumes/datasstore0/196-2012r2/’
Notice: It is not the actual image file you are looking at here. Just the configuration file - mush smaller.
2. Create a directory for the new clone from putty (You can use the datastore name). Like:
3. Clone the vm using the vmkfstools -i command with or without the optional thin option. By default, the vmkfstools -i command will create a thick provisioned disk. If you want the destination disk to be thin provisioned, add -d thin.
Would be nice, if the job was shown in the console - but you will not see this clone job in the vSphere client task list. So it goes. After the process has completed, two new .vmdk file have been created:
You cannot register these files from the vSphere Client – these files are just the hard disk. The configuration information is still missing. Instead you must create a new VM from the client, and attach the file/disk you have just cloned.
Can easily turn in to a bit of a mix-up, with file/directory names. Cloned file and directory before doing anything in the vSphere Client. I.e. the source for the new VM: /vmfs/volumes/datastore0/196-2012r2/196-2012r2.vmdk. Therefore I like this VM to be: 196-2012r2. Make sense.
Therefore we need to create a new VM from the vSphere Client. Not 100% sure this is necessary, but as this is a clone of a running VM, I assume CPU configuration need to be identical with the original VM. Not sure. Source VM had 4 CPU's, so the clone is also getting 4 CPU's. Likewise choosing identical controller of the source VM.
Name and guest OS: Choose a silly name for the new VM. I will use '196-2012r2'. For the 'Compatibility', 'Guest OS family' and 'Guest OS version' I will choose settings from the original source VM. 'vmkfstools' do not remove VMware tools from the clone.
Select storage: Must be the datastore where the clone was saved. In my case: datastore0.
Customize settings: Delete the default created disk (Hard disk 1) and use 'Add hard disk' (add existing disk) Choose the created clone. In my case: 196-2012r2.vmdk.
Your clone is now created and registered in the vSphere Client. The VM target directory should now include two more files: