How to Clone Virtual Machine using vmkfstools Command on ESXi 5.5

Vmkfstools command offers the ability to clone the contents of VMware virtual machines(VM) from (.vmdk ) disk format to another without the help vCenter. This is very useful to anyone who does not have a license to perform vCenter cloning.

To change the virtual machine disks from one type to another, you must perform the following steps :

1. Turn off the source VM . The running VM disk file is locked while in use.

2. Create the destination VM folder :

~ # mkdir /vmfs/volumes/destination-datastore/vm2

3. From the ESX/ESXi terminal or ssh session, run the following command :

~ # vmkfstools -i /vmfs/volumes/source-datastore/vm1/vm1.vmdk /vmfs/volumes/destination-datastore/vm2/vm2.vmdk -d thin

Note : vm1 is the source VM and vm2 is the new VM which is located at the destination datastore :

Example :

~ # vmkfstools -i /vmfs/volumes/52a0db3f-d87636dc-61bb-28924a2f1bc0/CentOS6.5-VM1/CentOS6.5-VM1.vmdk /vmfs/volumes/52a0db3f-d87636dc-61bb-28924a2f1bc0/CentOS6.5-VM2/CentOS6.5-VM2.vmdk -d thin
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/52a0db3f-d87636dc-61bb-28924a2f1bc0/CentOS6.5-VM1/CentOS6.5-VM1.vmdk'...
Clone: 100% done.

4. Copy .vmx which is contain the VMware configuration file into destination VM folder :

~ # cp -p /vmfs/volumes/source-datastore/vm1/vm1.vmx /vmfs/volumes/source-datastore/vm2/vm2.vmx

5. Editing a virtual machine’s configuration file (.vmx) is require to reflect with the new VM name :

~ # vi /vmfs/volumes/source-datastore/vm2/vm2.vmx

6. To register the virtual machine from the command line:

~ # vim-cmd solo/registervm /vmfs/volumes/source-datastore/vm2/vm2.vmx

Example :

~ # vim-cmd solo/registervm /vmfs/volumes/source-datastore/vm2/vm2.vmx
319

Note : 319 is the virtual machine ID (Vmid) for vm2.

Leave a Comment

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