Virtual machines, or VMs for short, are an excellent tool. The ability to spin up a customized operating system and run it on your machine at any time has almost limitless uses.
While virtual machines can be handy for the everyday computer user, they’re priceless for software developers, testers, or anyone who works in the software development arena. They can be set up and configured for almost any operating system and hardware specifications.
The result? Dev teams can develop and test software in a wide variety of environments. The ability to create and then “clone” environments is one of the many benefits of using virtual machines.
What does it mean to “clone” a virtual machine? Let’s first take a look at what cloning means, then how to do it.
Table of Contents
What is Virtual Machine Cloning?
The word “clone,” when used as a verb, means to make an identical copy of something. In our case, we wish to make an identical copy of an existing virtual machine. The duplicate will have the exact same operating system, hardware configuration, software configuration, and installed applications.
When first created, the cloned machine will match the original in every area. As soon as it’s used, slight differences will emerge depending on the user’s actions. Configuration settings might change, files might get created on the disk, applications might get loaded, etc. Just logging in or creating a new user will change the system once new user data is written to the disk.
So, a cloned VM is really only an exact copy at the time of its initial creation. Once it’s started and used, it begins to diverge from the original instance.
Why Clone a Virtual Machine?
As a software developer or tester, you often need an environment to create and test applications. Virtual machines allow you to create a clean environment configured with the resources required for testing. As you use the VM, it can get corrupted from trying different development ideas or testing the software. Eventually, you’ll need a new one.
It can take some time to set up and create a new virtual machine every time you need one, so the best method is to create one original environment on a VM. Then, keep that one clean or unused. Any time a new one is needed, just clone the original. You’ll quickly have everything you need for your test or development environment.
This also works well when you have a team of developers and testers. Instead of everyone creating their own VM, they can simply be given a copy of an original that is already set up with everything they need. This allows developers and testers to get working quickly, also ensuring they start with the same environment. If anyone corrupts or destroys their machine, it’s easy to create a new one and start over.
How to Clone a Virtual Machine: Guide
You can read about the best hypervisors in our best virtual machine roundup. Just about every hypervisor has a feature allowing you to clone a virtual machine. We’ll show you how to do so using the 3 hypervisors we have listed above. Most others use similar methods.
Use the following method to clone a machine in VirtualBox. Note that these commands can also be run from the menu at the top of the VirtualBox application.
Step 1: Startup VirtualBox on your desktop.
Step 2: Ensure that the VM you wish to duplicate has all applications installed, is configured how you want, and is in the desired state. Remember that each copy will start in the same state and configuration. Once ready, it’s best to shut the VM down before cloning it.
Step 3: In the list of virtual machines on the left panel of the VirtualBox application, right-click the one you wish to clone. This will open the context menu.
Step 4: Click “Clone.”
Step 5: You will then be prompted with some configuration options—the name of the new instance, where you want to store it, etc. You can keep the defaults or change them to your preferences. Once you have your options selected, click the “clone” button.
You will now have an exact duplicate of your original VM that you can use or give to someone else on your team.
VMware has a similar process. You can use the following steps in VMware Fusion.
- Start the VMware Fusion application.
- Ensure the virtual machine you’re copying has all the required applications and is configured the way you want it.
- Shut down the machine before cloning it.
- Select the VM you want from the virtual machine library.
- Click on the virtual machine, then create a full clone or a linked clone. If you would like to instantiate it from a snapshot, then click on Snapshots.
- If you selected the option to create a clone from a snapshot, right-click and then select a full clone or linked clone.
- Type in the name of the new version, then click “Save.”
For Parallels Desktop, use the following steps or refer to this guide from Parallels.
- Start Parallels and make sure the VM you want to use as your original is configured and in the state you wish to copy. Also, make sure that it is shut down.
- In the control center, select the VM and then choose File->Clone.
- Select the location in which you want to store the new version.
- Click “Save,” and then it will be created.
When creating a clone using most hypervisors, you will be given the option to create a full clone or a “linked” clone. You may be wondering what the difference is.
Full gives you a stand-alone virtual machine that runs on its own in the hypervisor, while a linked one has its resources linked to the original VM.
There are advantages and disadvantages to using a linked clone, so you may want to know what they are before deciding which one to use.
A linked clone will share its resources, which means that it will take up much less space on your hard drive. Full clones can use a great deal of disk space.
Another advantage of using a linked clone is that when you make changes to the original VM, the linked versions will be updated. That means there’ll be no need to create a new one every time a change is made to the original. However, this could be considered a disadvantage if you don’t want those changes to affect your duplicated environments.
Another disadvantage of linking is that the machines may run much slower, especially if you run more than one at a time. Since the resources are shared, the linked VM may have to wait its turn to use needed resources.
One more disadvantage is that the linked machine is dependent on the original VM. You won’t be able to copy the clone and run it on another machine unless you also copy the original to the same area.
Also, if anything happens to the original—such as it getting deleted accidentally—the linked copies will no longer work.
A clone of a VM is actually just a copy of that virtual machine in its current state. Cloning can be beneficial, especially for those who work in software development. Virtual machine clones allow us to make copies of a specific environment so that we can reuse them and not have to worry about destroying the original.
When creating a new clone, you will need to decide if you want to create a full or linked clone. Be sure to take into account the advantages and disadvantages that we have talked about above.
As always, please let us know if you have any questions or comments. We would love to hear from you.