Clone a VM without vCenter in ESXI 5.x Free Edition


Vmware-Logo


Introduction:

Esxi-LogoA couple days ago I was setting a new test environment at my house using a old Dell Precision 690 workstation. I started out by creating a couple VM’s and then slowly updated each then configuring them from there. This was taking way to long so I started looking into the ability to properly clone and create a VM that I could use as a template.

Now from my understanding the free version of ESXI 5.5 (Version I am using) has the abilty to clone VM’s but not via the GUI. If someone knows of a way via the GUI leave a comment as I would be interested in knowing.  So anyway I was able to deduce how to do it via the command line.

It actually was surprisingly simple and quick. So for this article I will show you how to setup a VM to be used as a template, sysprep that machine and then use that template to create new VM’s for fast deployment.


The Template Over-View:

About VMware vSphereVMware vSphere is the most robust virtualization solution today in my opinion. Cloning a Virtual Machine  in ESxi 5.5 is a feature of vCenter server. Out of the box vSphere free edition hyper-visor does not support cloning. But there is an alternative way to clone a VM.

To keep things simple I wont go over how you should configure your template since it will all depend how what your situation calls for. And the end steps will be the same for all machines. Though to give an example of the template VM I created for this test:

Server 2012R2 Standard (not domain joined)

No Roles or features setup

Pubilc/Private Firewall-disabled

Remote desktop enabled

Fully Updated

Time-Zone Set

A test folder located at C:\Test-Folder with a few random documents

So basically this was a fully updated Server 2012R2 system with some generic configurations that I know will be the exact same on every VM I want to create.


Lets start making the Template:

Start by login into your ESXI 5.X server

Vmware-Login

Now create a new VM and configure it anyway that you want.  (I used a Server 2012R2 as my template) After you have the VM to the point where you would like to make a template you will need to run a sysprep on that system to generalize they system so that it can be used multiple times as a template. In case of windows 2012R2 sysprep is included in the windows installation, under the folder c:\windows\System32\sysprep. This utility exists for other Windows versions as well.

Run sysprep and select Enter System Out-of-Box Experience, check the Generalize box and select Shutdown. After the system shutsdown you will be able to start the cloning process.

Vmware-Server2012R2-SysprepSysprep


Lets Clone a VM:

Now you dont have to but I did, I created a snapshot of the Template VM just in case something go screwed up in the cloning process. To take a snapshot Right click the vm and make a snapshot. Give it a name and some description and your done.

Now enable the ssh service on your ESXi by going to the configuration tab and the security policy option. Just start it for the moment, you don’t need to set it to start automatically. Use a ssh client like putty and connect to the hypervisor. Browse the folder under /vmfs/volumes path. It should look like this:

Vmware-Datastore-3Then:

cd /vmfs/volumes/datastore1 (Or what ever your datastore is called)

ls -l

This will display your VM’s which are located in the /vmfs/volumes/datastore1 folder. You should see the template vm that you created, so next you will want to create a new folder to place the cloned VM into.

mkdir yourvmname

and then run the following to clone to template to the new folder:

(I cloned the template snapshot you don’t have to you can grab the original .vmdk if you want)

vmkfstools -i /vmfs/volumes/datastore1/template/template-000001.vmdk /vmfs/volumes/datastore1/newcloneVM/newcloneVM.vmdk -d thin

The screen will show the progress the cloning process is at, it took me about 3-5min roughly to clone my template vm to the new folder.  To see more about the vmkfstools command you can run the following:

man vmkfstools

Finally we will want to create a new custom VM in ESXI using an existing disk file.

Vmware-Clone1 Vmware-Clone2

Browse your datastore and select the name of the folder that has your clone template in. Not the template but the cloned drive. Select the .vmdk file in there and continue the setup process. After completing the setup power on the machine and you will probably have to run through some basic setup settings, but you should now have a cloned vm, where in my case is fully updated, already has the firewalls disabled and I can see my test folder in the c:\ drive.


Thank you

cropped-logo3.png

Leave a Reply