How to clone or copy VMware Player VM

In some cases you may need to create vanilla Linux virtual machines (VMs) from scratch many times. In other times you may want to duplicate particular system settings of one VM to multiple other VMs. Whatever the reason may be, being able to clone or copy an existing VM turns out to be extremely useful. If you have a VM running on VMware Player, it's easy to make a clone of the VM. The following guide has been tested with VMware Player 5.

First, power off the VM you would like to clone. Then make a copy of the directory where the existing VM's .vmx file is stored. I assume that the existing VM's directory is "vmware/alice". I copy that directory as "vmware/alice_clone".

$ cp -r vmware/alice vmware/alice_clone

Rename all alice.* files (including alice.vmx) in "alice_clone" directory to corresponding alice_clone.* files.

$ cd vmware/alice_clone
$ rename 's/^alice/alice_clone/' *

Edit alice_clone.vmx and alice_clone.vmxf in a text editor, and replace all occurrences of "alice" in the files with "alice_clone". The following command-line will take care of this editing automatically:

$ sed -i 's/alice/alice_clone/g' alice_clone.vmx alice_clone.vmxf

Now open alice_clone.vmx on VMware Player, and start the cloned VM.

When the cloned VM is about to start, VMware Player will prompt you with the following message:

Clone VMware Player VM

Choose "I copied it", and then proceed.

Once told that you copied your VM, VMware is smart enough to regenerate any information which needs to be unique across different VMs (such as MAC address of the cloned VM, or VM UUID). After having started the cloned VM successfully, you will notice that VMware Player has updated alice_clone.vmx as follows.

$ diff alice/alice.vmx alice_clone/alice_clone.vmx
66c66
 ethernet0.generatedAddress = "00:0C:29:72:33:19"
68c68
 ethernet1.generatedAddress = "00:0C:29:72:33:23"
75,77c75,77
< uuid.location = "56 4d 36 a3 43 16 0f 4f-78 ef 23 ad 9c 68 24 9e"
 uuid.location = "56 4d 83 7a 5e 2c 7f 0a-df c7 a7 2a 04 72 33 19"
> uuid.bios = "56 4d 83 7a 5e 2c 7f 0a-df c7 a7 2a 04 72 33 19"

After starting the cloned VM, don't forget to change its hostname, as the cloned VM has the same hostname as the old VM!

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

5 thoughts on “How to clone or copy VMware Player VM

  1. You might also need to manually edit the 'alice_clone.vmdk' file (representing the HDD) to replace any occurrences of 'alice'.
    Anyhow, this was a very helpful posting!

    Cheers!
    Radu

  2. Thanks. Here's a script I use on Linux to do the cloning
    ( http://kegel.com/linux/vmware-clone.sh.txt ):

    #!/bin/sh
    # Trivial script showing how to clone a VM; usable with vmware player 5
    set -e
    set -x

    from=win7-vm2
    to=win7-vm3

    mkdir $to
    cp -a $from/caches $to
    cd $from
    for f in $from*
    do
    g=`echo $f | sed "s/$from/$to/"`
    cp $f ../$to/$g
    done
    cd ..

    cd $to
    sed -i "s/$from/$to/g" $to.vmdk $to.vmx $to.vmxf
    cd ..

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *