ESXi Cloning

ESXi is virtualisation for the enthusiast, the underpaid or tight-fisted. To stop you just installing at and having it all your own way it is limited in what it can do. The limits are generous except for the minor point about a lack of Telnet/SSH support. This means no RCLI. This obviously also means that the power tweakers and tinkerers (like me) are stuck with GUI clicking.

However, a master of the art named Andrew Bradley explains in his blog how to unlock the powers of RCLI and throws in instructions on how to clone your VMs for good measure. What a nice chap!

For the GUI-lovers though, at least you can play with SCP to backup your VMs onto another device. Finally – robust virtual machines for people with servers in their sheds. What do you mean you DON’T have a server in your shed? Oh dear.

So here is how I do it. I do  a good build of Windows XP Pro and Ubuntu and save them in a folder called “Templates” I created in datastore1 on the VI Client. Creating a new server from this template goes as follows:

VI Client:

  1. Go to the Summary tab and right-click the datastore
  2. Choose browse datastore and the contents are shown
  3. Create a new folder (e.g. ‘New Server’)
  4. Use VI Client to copy the VMDK from the template machine to this folder. In this case I’m copying from “\templates\windowsxp.vmdk” to “\New Server\”

PuTTy

  1. SSH onto the ESX server directly
  2. cd ‘/vmfs/volumes/datastore1/New Server’
  3. mv ‘WindowsXP.vmdk’ ‘New Server.vmdk’
  4. mv ‘WindowsXP-flat.vmdk’ ‘New Server-flat.vmdk’
  5. vi ‘New Server.vmdk’
  6. change the -flat.vmdk filename for the Extent Description to be the new filename
  7. [Esc] :wq! to save/exit vi

Back to VI Client:

  1. Create a new custom VM
  2. Name it the same as your folder name (eg. ‘New Server’)
  3. When prompted for datastore, choose custom and browse to the newly renamed vmdk
  4. Finish creating the VM (note: I use buslogic adapters)
  5. Start the VM

Console tab for your new VM

  1. Start, Control Panel
  2. System
  3. Under the Computer Name tab, click Change
  4. Give it a new name
  5. Restart when prompted

All done.

You can obviously copy your VMDK and -flat.VMDK files off to other storage from time to time so long as the VMs are turned-off. Effective if luddite backup….

[UPDATE: Scripted cloning for the lazy is now available: http://www.pgregg.com/projects/vmclone/]