Clone Virtual Machine on VMware Server 2.0

When you need a bunch of virtual machines with the same set up is really boring setting every single on from scratch. Cloning of virtual machines is VMware’s ESX is only a few clicks away. For the VMware Server product you need a bit of extra work as it lucks that functionality.
Bellow are some simple steps to get a virtual machines cloned:

  • Create a new directory named after the name of the new virtual machine. You’ll need to create in the directory you decided to host the virtual machines. This is usually /var/lib/vmware/Virtual\ Machines
  • Copy the disk image of the virtual machines you want to clone into the newly created directory and name it after the name of the new virtual machine. [ shutdown the existing virtual machine before copying the disk image ]
  • Copy the vmname.vmx and vmname.vmxf files form the directory of the existing virtual machine into the directory of the new virtual machine.
  • Changes in vmname.vmx:
    – Replace all the entries that contain the existing virtual machine’s name with the new name. These are the values of the attrubutes: nvram, displayName, extendedConfigFile and scsi0:0.fileName. The last one may be different depending on the controller you’ll be providing to the virtual machine.
    – Replace the existing UUIDs (you can generate new ones using the uuidgen command).
    – Replace MAC address (you can change just a few digits).
    – Replace the (change a few digits here as well).
  • Changes in vmname.vmxf
    – Replace the existing VMId with a new id generated by uuidgen.
    – Replace the vmxPathName attribute.

Once you are done with all these, you can launch the VMware Infrastructure Web Access (type vmware in the console) and add the cloned virtual machine in the inventory:

  • Virtual Machine -> Add Virtual Machine to inventory -> Select the new virtual machine from the inventory.

You can now start up the cloned virtual machine. You’ll need to change a couple of things in the OS settings of the virtual machine:

  • /etc/hosts -> Replace old hostname with new one
  • /etc/sysconfig/network -> Replace old hostname with new one
  • /etc/sysconfig/network-scripts/ifcfg-eth0 -> Replace MAC address with new one and any other settings specific to the host

12 thoughts on “Clone Virtual Machine on VMware Server 2.0

  1. Excellent article. Just a few more things.. i had to restart vmware
    /etc/init.d/vmware restart
    I don’t know why but even though i replaced everywhere in config, i had to click on it in the list and manually rename it.
    When i powered it made me admit i messed with it and it asked whether i copied or moved it. I said copy and now it runs

  2. panoskrt

    Thank you Andrei 🙂
    Why did you restart it? What was the problem? I didn’t have to restart the daemon. You just copy files and then add them to the inventory as an existing VM, shouldn’t need any restart.
    For the list renaming, I’d imagine you forgot to edit the displayName attribute in foo.vmx.
    I faced the copy/move question when copying VMs on VMware Workstation however not this time with Server. I think it has to do with the id assigned to the VM, though I’m not sure. However, it’s not a problem, as you probably realised yourself, you reply to the question and then it’s working normally. It’d be interesting to check if there’s a new id generated after answering the question.

  3. kplusalot

    One additional item. If the original VM has a snapshot and the snapshot file (*.vmsn) contains an absolute path to the original vmdk hard drive file, then a clone using this method is not possible. The vmsn file would need to be manually reconfigured, but the structure of the file does not allow this as it is partially binary. At least I have not found a way to do it.

    If you remove the snapshot first, then this is no longer an issue. Even if the vmx file contains an absolute path, it is a normal text file that can easily be modified. Remove the snapshot for the original VM through VMware Infrastructure Web Access before you copy the files and make the modifications listed above and then add the cloned VM to the inventory.

  4. Pingback: Ubuntu 8.04 LTS Dynamic DNS with nsupdate « Matt’s Blog

  5. Pulin

    thanks for nice article, can u help me doing the same on Windows 7 + VMware Server 2.0??
    I am using these combination and want to clone Centos 5.5
    Not able to figure out the uuid changing in windoew7 and few other steps. If u can pls guide me through this.
    would appreciate ur help
    thank you

  6. panoskrt

    Pulin, the .vmx and .vmxf should be the same on both platforms. I haven’t tried VMware server on Windows neither I have access to a Windows 7 platform. Let me know which steps and what doesn’t work exactly and we may get something out of it 🙂

  7. Pingback: Paul Weinstein

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s