Microsoft introduced Hyper-V as a virtualization platform in 2008, and it continued to release new Hyper-V versions with new Windows server versions. Since Hyper-V’s debut, it has always been a Windows Server feature, which could be installed whenever a server administrator decided to do so. It’s also available as a separate product called Microsoft Hyper-V Server. These days its also available in the Windows Client OS versions since Windows 8. So IT Pros and other people can quickly create their own VMs (or Virtual Machines) as and when they need it.
Cloning Virtual Machines refers to creating another copy of the existing virtual machines. It is a very useful feature from deployment standpoint of view, which allows a system to be copied and duplicated without the need to perform installation again. In addition, cloned virtual machine also preserves current system and apps environment in production, allowing testing and evaluation to be done before any changes or updates been applied to production virtual machine.
If you right click the existing virtual machine in the Hyper-V Manager Console, you would not find any option to clone:
However this can simply be overridden by exporting and importing the virtual machine.
Exporting the existing VM
Before cloning a VM, you may want to prepare the source VM with the Sysprep utility to reset and remove the unique security identifier (SID) for the VM, and avoid issues such as two computers have a same IP address or two computers have the same computer name. This step is recommended for VM that is joined to Active Directory (AD) domain on the same network, but is not required most of the time, and can usually be skipped for virtual machines running as workstation. Once its done, right click the existing VM in Hyper-V manager console and select ‘Export’:
Specify the location where you want to save the exported VM. You can click on Browse button to select a folder:
Avoid choosing the same location as the .vhd file (virtual hard disk file) for the existing VM.
Import the saved VM files
From the right pane in Hyper-V Manager Console, select the ‘Import Virtual Machine’ option:
This will open a pop-up wizard for you. In wizard, click next and then specify the location where you saved the files during export time:
Click next, and then it will show the name of virtual machine if its able to read the exported files. Click next here and select import type as shown:
We have chosen the third option as we would not like to interfere with existing VMs in the console. Click next and it will ask to specify a folder location to store the virtual machines configuration files. You can leave it as default as Hyper-V will create a unique ID for the cloned VM:
Click next and it will ask to specify a folder location to store the virtual machines file (.vhd files). Here you must specify a folder location which is different from virtual hard disks of source virtual machine if you’re cloning the VM on the same host, which is the case for this blog post:
Click next, review the summary shown and then click finish.
It may take few minutes to complete the import process depending upon the size of the existing virtual machine. If existing VM has any snapshots or saved state, this method preserves the same. So its better than simply copying and pasting the vhd files using windows file explorer.