Cloning VM’s in ESXi

//Cloning VM’s in ESXi

.vmdk files in VMWare

Here is a quick hack if you wish to quickly clone virtual machines on an ESXi server without using Virtual Center.

  • Login to ESXi using ssh or the console;
  • Create the target folder (using DataStore browser or cmd line)
  • The command we need to execute is below
vmkfstools -i 
/vmfs/volumes/datastore/sourcevm/sourcevm.vmdk 
/vmfs/volumes/datastore/destvm/destvm.vmdk ↵

However, its easier to script the whole process if you have multiple DataStores.

SOURCEVM=$1
TARGETVM=$2
DATASTORE=/vmfs/volumes/$3
DATASTORE2=/vmfs/volumes/$4
mkdir $DATASTORE2/"$2"
vmkfstools -i $DATASTORE/"$1"/"$1".vmdk $DATASTORE2/"$2"/"$2".vmdk

After this, create a custom VM, and use the vmdk disk you just cloned.

Comments

2015-09-07T19:43:11+00:00 February 7th, 2012|Infrastructure|