Quick down and Dirty script to clone hard Drives in the free version of ESXi (assuming you have ssh access)
I was looking for an easy way to clone a VM without VirtualCenter and came across this, which worked like a charm, bits of which I had done before for other purposes...
http://hsukumar.wordpress.com/2008/05/14/esx-clone-without-virtual-center
So I came up with a little automation, good for when you have to "create a few"... Change according to your datastore!
Script: clone-system name-of-source-vm name-of-target-vm
SOURCEVM=$1
TARGETVM=$2
DATASTORE=/vmfs/volumes/MY-VM-STORE
mkdir $DATASTORE/"$2"
vmkfstools -i $DATASTORE/"$1"/"$1".vmdk $DATASTORE/"$2"/"$2".vmdk
And I then enhanced it a bit more, to also check for a second drive, and allow for 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
if [ -f $DATASTORE/"$1"/"$1"_1.vmdk ]
then
vmkfstools -i $DATASTORE/"$1"/"$1"_1.vmdk $DATASTORE2/"$2"/"$2"_1.vmdk
fi
if [ -f $DATASTORE/"$1"/"$1"_2.vmdk ]
then
vmkfstools -i $DATASTORE/"$1"/"$1"_2.vmdk $DATASTORE2/"$2"/"$2"_2.vmdk
fi
So, just copy the script above, do a vi clone-drive.sh, then hit "i" and paste, then esc, then :wq then chmod 700 clone-drive.sh
To Execute: clone-drive.sh name-of-source-vm name-of-target-vm source-datastore target-datastore
Then, just create a new (Custom) virtual machine in the GUI with the same NIC's, etc, and attach the new hard drive(s) you just cloned to it while creating it (you should use the same name as the name-of-target-vm above)
Enjoy!