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

~ by panoskrt on January 20, 2009.

18 Responses to “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. 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. 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. Aha, good point kplusalot. Thanks for clarifying that.

  5. […] To assist in this effort, I have been working a VM clone script based on the information described here. One of my requirements in deploying identical systems is that cloned VMs should contain a proper […]

  6. Great article, thanks :)

  7. Hi! Very helpfull and well outpointed article. Saved me a lot of time. Keep going on this way. Thanks a lot an kind regards from Austria.

  8. 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

  9. 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 :)

  10. thank you!

  11. Very useful, thanks!

  12. Highly energetic article, I liked that a lot. Will there be a part

  13. Hello, I would like to subscribe for this blog to
    take hottest updates, therefore where can i do it please assist.

  14. Good post. I learn something totally new and challenging on sites I
    stumbleupon on a daily basis. It’s always exciting to read through content from other authors and
    use a little something from other web sites.

  15. It’s remarkable tto pay ɑ quick visit tɦis website and reading tthe views
    of alll mates οn the topic of this paragraph, while Ӏ am also eager of
    ǥetting knowledge.

  16. Very shortly this website will be famous among all blog people, due to it’s pleasant articles

  17. Excellent article. I certainly appreciate this site.
    Keep it up!

  18. You should take part in a contest for one of the highest quality
    blogs on the web. I most certainly will recommend this web site!

Leave a Reply

Fill in your details below or click an icon to log in: 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 )

Google+ photo

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

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: