How to Clone VM without vCenter

vmware logo

vCenter is really straightforward for tasks like cloning a server image. ESXi, however, is rather spartan when it comes to features. Many management tasks can still be performed with command line interface by using a tool like PuTTY.

You just got a new bare metal server and you want to setup VMware ESXi and vCenter but a prerequisite for installing vCenter is a configured domain. If you are working in an environment without a Domain Controller then you will have to configure a VM to be a DC on your VMware ESXi host and setup a domain before you can install vCenter. Once vCenter is installed most management tasks are quite easy to accomplish with vSphere.

My endpoint goals:

  • Virtualize a physical server
  • Install ESXi on bare metal host
  • Install vCenter to manage VMs

The author assumes you have installed VMware ESXi 5.x or 6.x hypervisor on your host server and configured the basic parameters like IP address, subnet, gateway and host name. Outline of steps to create a master VM image:

  1. Create a VM
  2. Install OS
  3. Install VMware tools
  4. Update OS with the latest updates
  5. Install any apps you want on the master image
  6. Configure any settings you prefer on all your servers
  7. Follow steps below to clone

Steps to clone VM using only the bare metal install of ESXi:

Take a snapshot of the server you would like to use as the master image

Take Snapshot

Enable SSH on the host. Select the host > go to Configuration tab > Security Profile > Properties

turn on SSH

Scroll down > select SSH > click Options

Start SSH - Options

Start the service, you can stop it later to minimize security risks.

Start SSH

Download PuTTY and open it to establish an SSH connection. Input the IP address of your host to connect. In my case the host IP is 192.168.1.3. Enter the root username and password in PuTTY to login to the host.

Navigate to your master VM to verify it is the location you expect by running these commands in PuTTY:

cd /vmfs/volumes
ls -la
cd datastore1
ls -la

Find Source

Create a Directory called Clone to store clone images.

mkdir Clone

If your snapshotted source VM is “DC1” located on “datastore1” the following is the command to clone the VM called DC1. The “-000001” suffix on the VM name is to capture a snapshot version. If there was no snapshot you could just have “DC1.vmdk” at the end of the source path. Paste this entire command as one piece:

vmkfstools -i /vmfs/volumes/datastore1/DC1/DC1-000001.vmdk /vmfs/volumes/datastore1/Clone/VC1.vmdk -d thin

cloneVM-SSH

“Clone” is the folder where it will be stored and “VC1” is the name of the cloned virtual disk. “-d” is for the disk format, in this case thin provisioned. We will now create a new VM in vSphere and use the existing virtual disk.

Create a new VM in vSphere

create new VM

Select Typical

create new VM 2

Name the VM

create new VM 3

Select the target datastore

create new VM 4

Select the guest OS, in my case Server 2012 R2

create new VM 5

The default is 1 NIC, which is fine but I prefer to add a second internal NIC for VM to VM traffic that I previously setup

create new VM 6

Put whatever you want here because you will be deleting it anyway so you can add the cloned VD you already saved

create new VM 7

Select Edit the virtual machine before you continue

create new VM 8

In the Edit window, select the “New Hard Disk” you just entered parameters for and select Remove

create new VM 9

Select Add

create new VM 10

Select Hard Disk

create new VM 11

Select Use an existing virtual disk

create new VM 12

Browse to your Clone folder in the appropriate datastore, for me it was datastore1

create new VM 13

Next > Next > Finish

create new VM 14

Hooray, you have just created a cloned VM using command line!

create new VM 15

Hope this helps!