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:
- Build a virtual machine with your OS of choice. *cough* Linux *cough*
- Enable ssh into the ESX host
- ssh into the host
- Go into the datastore in which you created your VM
- 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.
- Go into the datastore you are going to keep your new VM.
- Make a new directory – I always call it the same as the short name of the VM I am creating
- Copy only the .vmdk files into the new directory you’ve created.
- Logout, and fire up the Virtual Infrastructure Client, and create a new VM as you normally would.
- 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/

Absolutely wonderful. It works, and it’s so simple !! Why bother in installing lots of windows interfaces ??
Furthermore i would recommend to rename cloned disks, and editing the file with the infos on the disks correctly with changed names.
Thats very good to know… thanks
you dont need to login to ssh to copy files, you can browse datastore,and do the same.
Thanks for the tip. That’s helpful to know for those without ssh access into the ESXi server or who pay attention to support warning banners displayed at login.
Hello,
thank you for the tips. But, what’s “Tech Support Mode”? And how can it be accessed? Thank you.
Tech Support Mode is simply what VMware calls accessing the ESXi host shell prompt via SSH. You have to configure the VMware firewall to allow incoming ssh connections in order for this to work, but after that, you just use your ssh client to connect the host and use the same credentials you would use to access it via the vSphere client.