I always strive to write about topics I’ve spent time researching or commonly reference.
It’s easy to overlook simple tasks that can save hours of work for all of you. Although Hyper-V 2012 R2 is beginning to find its way into more corporations with the automation assistance of System Center Virtual Machine Manager (SCVMM), which by the way is an effort of an install yet well worth it for the features gained, occasionally you still need to get your hands dirty.
I’ve found instances where I may have a host that isn’t joined to SCVMM, such as in a lab environment, or moving between different versions of Hyper-V where importing a VM is extremely time saving.
While it has been possible to export a Hyper-V VM for some time, prior to 2012, the VM needed to be powered off. This was due to the lack of Live Merging of Virtual Disks.
In 2012, a differencing disk is created to hold changes to data while the Export is being created from the parent disk. After the Export completes, the Differencing disk is then merged back into the parent disk. “GREAT!”, you may say to yourself, “But why should I care?” To which I say, because this allowed the ability to live migrate Virtual Machines between Hyper-V Hosts!
What’s more is that in Windows Server 2012 R2, Hyper-V now gives us the ability to import virtual machines that were not previously exported. This is extremely helpful in situations where a host OS becomes corrupted, or if the most recent good backup of a VM is a file-level backup of the virtual disks and XML configuration files. Also, if you still prefer to use the Export, you can save to a Network share in 2012 R2, which was previously not an option.
Note: XML Configuration files were not standard until 2008 R2.
Exporting is a simple right click context command on VM’s in Hyper-V Manager — Choose the Location to save the Export — Watch the export progress in the Status Column of Hyper-V Manager or PowerShell via the command Get-VM.
Here is how to accomplish the import:
- In Hyper-V Manager, Action – Import Virtual Machine
- Choose Folder Path containing the export, or VM folder. If prompted, choose the folder path containing the XML configuration files as well.
- Select the VM to be imported and click Next. If the Folder being imported is already the desired location, set Import Type to “Register the virtual machine in-place” and it will quickly register the virtual machine without the need to make a copy of the files. If you are importing for a source containing several virtual machines, you’ll most likely want to select either “Restore the virtual machine” or “Copy the virtual machine.” The latter creates new unique identifiers for the machine and may be needed for Import from network location. Choose Import Type:
- Choose your Destination folder path.
- If the virtual switches that were previously attached cannot be found, you will be prompted to select new ones. Don’t worry, you can adjust these later if you prefer.
- Confirm all looks good in the summary and click Finish. Make whatever adjustments you need to the VM settings and power up VM.
All of this is accomplished by using the GUI, but it is important to note that imports and exports can also be performed via PowerShell. You do use PowerShell, don’t you? (You definitely should be…)
You can find more information on these options by reading the ‘oh so thrilling’, Hyper-V Cmdlets in Windows PowerShell – it’s a real page turner! Side note: If you are engrossed in online reading material, is it known as a ‘real wheel scroller’…