You are hereCloning a VM in VMWare ESXi 4.0 without vCenter
Cloning a VM in VMWare ESXi 4.0 without vCenter
Click here for original article
VMWare ESXi is a FREE bare-metal hypervisor that lacks the plethora of management tools found in the commercial version. That being the case, you can still find some powerful yet hidden features behind the command line. If you feel comfortable at the command line, VMWare ESXi will not disappoint you.
One of the hidden features is the act of cloning a virtual machine. This is one of the places virtual machines shine in comparison to the traditional act of building a server. You take the time to build parent VMs that are than cloned every time you need a new server. I loved the reaction I got from a developer who asked for a server and I delivered his IP Address and login within 15 minutes.
In VMWare ESXi, the documentation directs cloning to VMWare vCenter Server (formally called VMWare Virtual Center). Unfortunately for me, this costs money and I can't afford it. If you would like to clone virtual machine on an ESXi server without the help of vCenter here are the instructions to do so.
- Log onto the ESXi host server via SSH. If you have not yet enable SSH, follow the instructions here.
- Create a directory for the new guest VM.
mkdir /vmfs/volumes/datastore/destvm - Next, run the vmkfstools command to clone the VM to the destination folder
vmkfstools -i /vmfs/volumes/datastore/sourcevm/sourcevm.vmdk /vmfs/volumes/datastore/destvm/destvm.vmdk
Enter the above command in one line.
This step takes awhile. You will see something similar to the following.
Destination disk format: VMFS zeroedthick Cloning disk '/vmfs/volumes/datastore/sourcevm/sourcevm.vmdk'.... Clone: 100% done.
- Now, go to the vSphere client and run File > New > Virtual Machine...

- Select Custom and click Next.

- Enter a Name for your destination virtual machine and click Next.
- Choose a datastore and click Next at the Datastore dialog box.
- Select the appropriate Virtual Machine Version and click Next. (In my case, the Parent VM was created in ESX 3.5i so I had to choose Version 4)

- Select the appropriate Guest Operating System: and click Next.
- Select the appropriate Number of virtual processors: and click Next.

- Configure the Memory Size and click Next at the Memory dialog box.

- Choose the correct settings for your network under the “Network” Dialog box.

- For the SCSI Controller select the same controller you choose in the Parent VM. If in doubt, take a look at the Parent VM’s *.vmdk file and look at the ddb.adapterType variable.
grep ddb.adapterType sourcevm.vmdk ddb.adapterType = "lsilogic"
- Click Next
- At the Select a Disk dialog box select Use an existing virtual disk. Click Next.
- At the Select Existing Disk dialog box, click Browse. Navigate to the folder you created in step 2.
- Select the disk you created in Step 3 and click OK.

- Click Next
- At the Advanced Options dialog box, select Next
- At the Ready to Complete dialog box, review all the settings for the new virtual machine and click Finish

- Power on your new Virtual Machine.

- Bask in the glory of your ingenuity and efficiency.
Thanks for the tutorial, I learned a lot.
I have a couple of questions though...
1) In the VM I want to clone there are 2 vmdk files. From what I've read that could be something to do with ESXi splitting the virtual HD into chunks. To follow your procedure would I clone both vmdk files and then select the first one to use as my existing disk when I come to create a new VM?
2) I followed an alternative procedure before this one which didn't work. It involved simply copying & pasting the .vmdk files from the datastore GUI in vSphere. I was just interested to know what happens during the "vmkfstools -i" process. Presumably it is more involved that just copying the file?
Thanks very much
...Just to update my point 1, I notice there are actually 3 .vmdk files from my source virtual machine:
VSSVR2000N01.vmdk (8GB, as specified)
VSSVR2000N01-000001.vmdk (33MB)
VSSVR2000N01-000002.vmdk (17MB)
Do you know what the 00001 & 00002 files are for? I only set it to use 1 disk afaik.
When I cloned them using your procedure they both ended up being 8GB in the destination dir.
Your -delta.vmdk files are snapshots. I am not sure if you need to commit (I.E. delete) these files before cloning the original file.
This article helped me clone my VMs without vCenter or any other VM tools, saved me time and money. Thanks for taking the time to post this info for us.
Hello,
I encounter an error on vmkfstools (step #2). I already try on all of my .vmdk files, but none of them works. Any ideas?
# vmkfstools -i /vmfs/volumes/datastore1/SBXRAC1/SBXRAC1_2-000001.vmdk /vmfs/volumes/datastore1/destvm/SBXRAC_CLONE-delta.vmdk
Destination disk format: VMFS zeroedthick
Failed to open '/vmfs/volumes/datastore1/SBXRAC1/SBXRAC1_2-000001.vmdk': The parent of this virtual disk could not be opened (23).
Thx,
-Chris
Remember you need to shut down (power off) your source VM before trying to clone/copy.
Muchas gracias por el tutorial! Funciono a la perfeccion.
En un momento me tiro DiskLib_Check() failed for source disk The system cannot find the file specified (25). Pero estaba escribiendo mail el directorio donde estaba el disco a clonar.
Saludos
Also ... just a note...
machine I was cloning had a snapshot of a point where I wanted to clone from...
Did the clone while the VM Was running..
Cloned only the snapshot (only snapshot) but worked great... never shutdown the vm and only got the part I wanted - pre-config joining domain and all!...
thx for this tutorial...
It was really good tutorial........It save my lot of time....
Thanks Again...
Great Tutorial.....Just maybe you can add the network part to make it complete for starters.
Post new comment