Monday, March 2, 2009

how to clone a VM in the free VMWare ESXi

In the free verison of ESXi, it's not obvious how to clone a VM, since you don't have VirtualCenter available.

I've read about some people using the free version of Converter, but this didn't work for me (Converter keeps hanging partway through the operation). Here's what I did; note that I'm running local storage only on an older host machine:

1) From the ESXi console, hit Alt-F1, then type "unsupported". You will get a bunch of dire warnings about this being an unsupported mode. You are now in a bare-bones Unix shell.

2) (optional) Enable ssh so you can do the rest remotely: use vi to edit the /etc/inetd.conf file and uncomment the line that starts with "ssh". Exit and restart inetd with "kill -HUP " where is the process ID of inetd. You can find the PID with "ps aux | grep inetd".

3) cd /vmfs/volumes/datastore

4) Use vmkfstools to clone the .vmdk file:

# vmkfstools -i imageA/imageA.vmdk imageB/imageB.vmdk
Destination disk format: VMFS thick
Cloning disk 'xubu1/xubu1.vmdk'...
Clone: 100% done.

5) From VI Client, create a new VM and select the custom option. When you get to the "select a hard disk" part, select the VMDK file you just cloned in the previous step.

6) You may have trouble with a cloned machine in Windows; you'll need to run sysprep to make it unique. In Linux you can just change the IP (if not using DHCP) and edit /etc/hostname and reboot to make a unique hostname.