poor man’s vm clonning under vsphere 5 without downtime

how to clone a virtual machine under vmware vsphere 5:

  • using the vsphere client create a new vm with similar parameters [at least the same number and size of hard drives]
  • using the vsphere client create a snapshot of the original vm
  • log in via ssh as root [ to enable the ssh access check this kb article ]
  • go to the folder where new vm is stored and remove all vmdk files
    cd /vmfs/volumes/datastore1/newVM
    #write down what are the names printed by command below
    ls -la *.vmdk
    rm -rf *.vmdk
  • go to the folder with the original vm and for
    cd /vmfs/volumes/datastore1/originalVM
    ls -la *.vmdk|grep -v flat
  • each vmdk file [one that DOES NOT have -flat part in the name] execute
    # for newvmname use the same names as displayed two steps ago
    vmkfstools -i oldvmname.vmdk /vmfs/volumes/datastore1/newvm/newvmname.vmdk
  • using the vsphere client remove a snapshot of the original vm

you’re done – you should be able to run the clone. it’ll have different mac address and you’ll have to configure again networking etc. snapshot created in this way will be crash-consistent. for some purposes it might be perfectly fine, for another – completely unacceptable.

Leave a Reply

Your email address will not be published. Required fields are marked *

(Spamcheck Enabled)