How to clone virtual machine with VmWare Server

Posted by Oleksiy Kovyrin under Databases · русский

Today I was doing some pre-release testing of our software and to test it I was needed three separate servers running MySQL. After some thinking I decided to use my “old” workstation (actually it is pretty powerful Sempron with 2Gb of RAM, but now I use my macbook as a primary workstation) and start 3 separate virtual servers there. Of course, as all admins, I’m little bit lazy and installing Debian on all three machines was not appropriate solution ;-) . So, I’ve created one machine, installed brand-new Debian Etch there and then begun to look for solution to clone this machine to run it in three copies. After all these operations were done, I’ve decided to spend time I’ve saved with this simple trick to describe here how to clone VmWare Server virtual machine without any pain.

First of all, we need to find where all our virtual machines are in our system. After small search I’ve found vmware files in /var/lib/vmware/Virtual Machines. There are some set of directories each corresponds to some of your already created virtual machines. In my case I was interested in cloning virtual machine with name db1 to new machine db2 and then to db3.

I’ve copied entire db1 directory to new one:

1
scoundrel@scoundrel-desktop:/var/lib/vmware/Virtual Machines$ cp -ax db1 db2

Next step was to rename virtual machine’s disk image (maybe it is not necessary but I decided that it would be better to perform this operation). To manage vmware disk images you could use vmware-diskmanager tool which resides in vmware’s binary directory (/vmware/bin in my case):

1
scoundrel@scoundrel-desktop:/var/lib/vmware/Virtual Machines/db2$ /vmware/bin/vmware-vdiskmanager -n db1.vmdk db2.vmdk

Next (and, actually, last) step was to rename virtual machine config and change disk image name in this config file:

1
2
scoundrel@scoundrel-desktop:/var/lib/vmware/Virtual Machines/db2$ mv db1 db2
scoundrel@scoundrel-desktop:/var/lib/vmware/Virtual Machines/db2$ sed -i 's/db1.vmdk/db2.vmdk/' db2

That’s it! Now we can start this new machine with VMware server console, it would ask as to change machine’s UUID (which is machines MAC address) and after uuid change this machine will get new IP address from dhcp server (in my case – wifi router). As always it was easy and funny. Stay tuned and I’ll say you why you should not use MySQL’s config file (my.cnf) to setup replication (this hint is for my next post).


Related posts:

  1. Typical Configurations Overview For Nginx HTTP(S) Reverse Proxy/Web Server
  2. How To Get “Provider Independent” IP Address For Your Home Server?
  3. Nginx – Small, But Very Powerful and Efficient Web Server
  4. Monitoring nginx Server Statistics With rrdtool
  5. Hosting Tricks: How to delegate DNS-management for some subdomain to off-site DNS-server

11 Responses to this entry

fabio says:

I can confirm it is not mandatory to rename vm disk.

So cloning VMs could be even faster!!

Would-be Cloner says:

I am using vmware-server-1.0.4-56528 on Ubuntu 7.10 and I cannot find the vmware-diskmanager utility. In fact, there is no /vmware/bin on my system. I built vmware-server and vmware-mui from sources, is there another package I should have downloaded?

Ken Garland says:

great write up. one quick note to more recent virtual server users, configs now have a .vmx extension on the end so you would do:

mv db1.vmx db2.vmx
sed -i ‘s/db1.vmdk/db2.vmdk/’ db2.vmx

in step three.

J42B says:

You might like to try running:
vmware-vdiskmanager
Look in /usr/bin
Also..might need to run with sudo