Cloning and Templates with VMware ESXi

Posted by Greg | Posted in TLF Blog, VMware | Posted on 24-12-2008

6

For those not familiar with it, VMware ESX is an enterprise-level virtualization solution packed with features, high-availability clusters chief among those.  For those that do not require these extra features, VMware had made, freely available, VMware Server, which ran on a single instance on top of Windows or Linux.  ESX, on the other hand, is entirely self contained and runs on the vmkernel.  In a move that i can only imagine makes it easier to manage a single code base, VMware did away with the Server product, to be replaced by ESXi, a stripped down version of ESX.  It is great for environments where high-availabilty is not necessary.

So now that you know what VMware ESX and ESXi are, let’s get on with it.  We started implementing ESXi internally, and to our dismay discovered one other feature that is missing from ESXi – the ability to clone virtual machines and to create templates.  Without cloning and templates, you lose out on one of the biggest advantage of using virtual machines, VMware or otherwise – rapid deployment.  I guess VMware wants you to purchase ESX if you need these features.

Unsatisfied with that assessment, I started digging around and came up with a procedure to be able to clone VM’s.  It’s more manual than using the ‘Clone to Virtual Machine…’ option in Virtual Center with ESX, but that’s what you pay the big bucks for – ease of management.  In a nutshell, this is what I did:

  1. Build a virtual machine with your OS of choice.  *cough* Linux *cough*
  2. Enable ssh into the ESX host
  3. ssh into the host
  4. Go into the datastore in which you created your VM
  5. Make a copy of the VM you just built

There you have your template.  In order to deploy it, it’s not as bad as one might think for a manual process.

  1. Go into the datastore you are going to keep your new VM.
  2. Make a new directory – I always call it the same as the short name of the VM I am creating
  3. Copy only the .vmdk files into the new directory you’ve created.
  4. Logout, and fire up the Virtual Infrastructure Client, and create a new VM as you normally would.
  5. When it asks about the disk, choose “Use an existing disk,” and select the copy of the vmdk.

The new Virtual Machine will have been created with the disk.  Boot the server up and change the network settings and customize to your heart’s content.  I’ve thrown in a sample session of creating the template and deploying it below.  Note that in you have to build the source VM first.


[root@tlf1 ~]# ssh tlfesx1
root@tlfesx1's password:

Tech Support Mode successfully accessed.
The time and date of this access have been sent to the system logs.

WARNING - Tech Support Mode is not supported unless used in
consultation with VMware Tech Support.

~ # cd /vmfs/
/vmfs/devices/ /vmfs/volumes/
~ # cd /vmfs/volumes/datastore1/
/vmfs/volumes/4946cee9-8d78d96a-2302-00137250f7df # mkdir template
/vmfs/volumes/4946cee9-8d78d96a-2302-00137250f7df # cp -p tlfsource/*.vmdk template/
/vmfs/volumes/4946cee9-8d78d96a-2302-00137250f7df # mkdir tlfnewsrvr1
/vmfs/volumes/4946cee9-8d78d96a-2302-00137250f7df # cp -p template/sda*.vmdk newserver1/