logo

Let’s Work Together

Partner with you to deliver responsive and cost-effective IT & Support solutions
Reponsive
Cost-Effective
Partner with you
Focus
Attitude to Serve
Professional
These are the reasons why AionSolution is your vendor when you are seeking someone to support your IT in your office.
info@aionsolution.com
+852 2636 6177

Cloning VMs on Linux Hosts with VMWare Server 2.0

think it’s a MAJOR pain not having a “clone” feature in VMWare Server without using Virtual Infrastructure, so I made my own Linux shell scripts to do it.

The clone script does a straight clone of a VM. It copies the directory, renames the files and tweaks all the text inside the files by using sed to replace the old name with the new one, then sets all the permissions to what they would be if you created a new VM.

The rename script basically does all but copy it. This is handy for if you tried to rename a directory manually or attempted a manual copy and then found it still shows up under the old name in the web console. Remember this one assumes you have already renamed the directory to the new name and it MUST be the same as what you intend for the new name to be.

Both work the same way… scriptname <old name> <new name>

You can use quotes around the names if there are spaces, I went to great lengths to make sure it would still work with spaces in names (although I personally hate spaces).

Save the scripts to the base directory where your VM’s are, “standard” location is “/var/lib/vmware/Virtual Machines”. Make executable with chmod +x <scriptname>.

Once ran, add the new/renamed VM to the web console and choose “I copied it” or “I moved it” as appropriate.

These scripts are offered free to everyone to use, modify, or do anything else you want with except take credit for the original version. Absolutely no warranty or guarantee of any kind on the part of anyone that they won’t hose your VMs or even your whole system.

If I understand correctly how the split disks work, the 3rd file attached (clone-split-disk.sh) should work for those VM’s. I have not tested it myself and will likely not get a chance anytime soon, so I will rely on feedback from the community for any near-future tweaking. This is really just a change to one line (line 34) in the file – in the original we exclude the binary .vmdk file from parsing to find-and-replace since this is how single-disk-file versions are saved; in this version we exclude -f???.vmdk where “?” is a number between 0-9 (i.e. files like -f001.vmdk, -f002.vmdk, etc) while we parse the .vmdk file since with split disks, the .vmdk is a text file describing the -f???.vmdk binary disk files. IF you use a combination of split disks and single-file disks, probably neither one of these will work – maybe in a future version I will be able to merge the two scripts and add logic to tell the disk types apart.

clone_vm
change_name
clone-split-disk