Exporting and importing virtual machines
If you don't want to perform an in-place upgrade from Windows Server 2008 R2 to Windows Server 2012, the migration from an old Hyper-V version to Windows 2012 is not so complicated either. You need to install a new server with Windows 2012, enable Hyper-V, export the virtual machine from the old server, and import them back to your new server. That's it! This is the same process that we have been using since the first version of Hyper-V in Windows Server 2008. However, the previous versions of Hyper-V had some limitations; for example, you could import only a virtual machine that had been exported before and lots of other issues regarding different configurations in the source and destination host.
The next few steps will guide you through the new process and options to import and export virtual machines introduced in Hyper-V 3.0.
Getting ready
Before you start to export your virtual machines, make sure they are turned off or in save state. You can't export a virtual machine with it running or in pause state.
How to do it...
The following steps will show you how to export and then import a VM back in Windows Server 2012. The export process can also be used in Windows Server 2008 and 2008 R2, so that you can import the VMs in Windows Server 2012.
- Open the Start screen and select Hyper-V Manager.
- Select the virtual machines you want to export, right-click on them, and select Export, as you can see in the following screenshot:
- In the Export Virtual Machine window, enter the path you want to export the virtual machines to and click on Export.
- Copy the exported virtual machine files to the destination host.
- Open Hyper-V Manager on the destination host and select Import Virtual Machine from the pane on the right-hand side.
- On the Before You Begin screen, click on Next.
- On the Locate Folder screen, specify the folder from which you want to import the virtual machine files and click on Next.
- In the Select Virtual Machine window, select the virtual machines to be imported and click on Next.
- In the Choose Import Type window, select the type of import, as shown in the next screenshot, and click on Next.
- If the source virtual machine has different virtual switches attached to it or different configurations that the destination host will not support, new windows can be displayed asking you to address the problem. The next screenshot shows an example of a VM with a different virtual switch name. Address all the problems or conflicts that the VMs have and click on Next.
- If prompted, specify the folders that you want the virtual machine files and disks in, and click on Next.
- Click on Finish when it is done and you will see the imported virtual machine in the Hyper-V console.
How it works...
The process to export the Virtual Machine (VM) collects its entire configuration file, snapshots, the Virtual Hard Drive (VHD), and puts all of them together in a new folder with the virtual machine name in the specified path during the export process. It's also possible to select more than one virtual machine and export them in just one go, in case you are migrating from old Hyper-V versions.
Windows Server 2012 Hyper-V introduces an improved and new process to import virtual machines. Firstly, you need to specify the folders where the virtual machine files sit. It does not matter if the virtual machines were exported or not. You can simply copy and paste the VM files and the result will be the same.
After that, the wizard shows a list of virtual machines that you want to import. The good news here is that Hyper-V lists the VMs as per their names and not by using the Global Unique Identifier (GUID). It makes the process easier.
The wizard provides three different types of import. The first type of import—Register the virtual machine in-place (use the existing unique ID)—assumes that all the files of the imported VM are in a single place and you have to just register the VM. It can be used to register VMs in a new host using the same VM path. The second one—Restore the virtual machine (use the existing unique ID)—is almost the same as the previous option, except that it allows you to specify the path of the VM files. Also, it copies the files to the new destination path. The last option—Copy the virtual machine (create a new unique ID)—creates new VMs with new IDs and can be very helpful when you just want to use the VM files as a template to create new VMs.
The problem with the previous versions of Hyper-V is when the VM has a different configuration in the source host. For example, if the VM has a different virtual switch or a hardware setting that is not present in the destination host, the import process would fail. Now the import is clever enough to identify whether the VM has conflicted or has different settings. Memory, processor, disk, networks, and file paths are checked and in case of problems, the wizard will prompt you to make changes, based on the destination limits and configuration.
When finished, your virtual machine will be ready to be started on the new server, making your migration much simpler.
See also
- The Migrating virtual machines and updating their integration services recipe in this chapter