Top Tips for Importing & Exporting your VM with Hyper-V
As you accumulate virtual machines, then sooner or later you are probably going to run into a situation in which you want to move one or more virtual machines to a new host server. Microsoft makes this possible through the Hyper-V Manager’s Import and Export functions.
If you look at Figure A, you can see that when you select a virtual machine, Hyper-V displays an Export link in the lower right corner of the console. There is also an Import Virtual Machine link at near the top of the Actions pane.
Read the Best Personal and Business Tech without Ads
Staying updated on what is happening in the technology sector is important to your career and your personal life but ads can make reading news, distracting. With Thurrott Premium, you can enjoy the best coverage in tech without the annoying ads.
The Import and Export functions are accessible through the Hyper-V Manager.
On the surface, it appears that you can simply select a virtual machine, export it, take the exported image to another server that’s running Hyper-V, and import it. On some levels this really is the way that the import and export processes work. There are some gotchas that you need to be aware of though, and the only way that you can avoid those gotchas is to understand what’s really going on when you export and import a virtual machine.
Virtual Machine Identification
The first thing that you need to understand about the import and the export process is that Hyper-V has two different ways of identifying virtual machines. The most obvious way of identifying a virtual machine is by the name that you have assigned to it. For example, if you look back at Figure A, the Actions pane will show you that I have selected a virtual machine named Posey-IM. Virtual machines retain their name throughout the import and export process. Although it is certainly advisable to avoid having multiple virtual machines with the same name, it is not an absolute requirement.
The reason why virtual machine names do not absolutely have to be unique is because there is a second factor that identifies a virtual machine. This second identification factor is the virtual machine’s Globally Unique Identifier, or GUID, which is automatically assigned to a virtual machine by Windows, and does have to be unique.
The Virtual Machine Export Process
The virtual machine export process itself is actually really simple to perform. Simply select a virtual machine from the Hyper-V Manager, and then click the Export link. After doing so, Windows will display the Export Virtual Machine dialog box that is shown in Figure B. All you have to do now is to enter the path that you want to export the virtual machine to, and then click the Export button.
The process of exporting a virtual machine is really simple.
So what’s so tricky about the export process? Well, not a lot really, but there are still some things that you need to know about it. For starters, Windows will place the virtual machine within a sub folder that bears the virtual machine’s name within the path that you have specified. For example, I decided to export a virtual machine named R2. Not wanting to lose the files among other clutter, I created a folder named C:\R2 and specified that as the export path. What I ended up with was the exported files residing in a folder named C:\R2\R2\.
One of the big questions that I had about the export process before I began was whether or not it left the original virtual machine instance intact, and in its original location. I’m happy to report that the files making up the virtual machine are untouched during the export process. This does however, mean that you will have to manually remove those files once you have moved the virtual server to its new location.
The other thing that you need to know is that depending on the size of the virtual machine, the export process can take a really long time to complete. Unfortunately, I can’t tell you exactly how long, because the amount of time depends on the size of the .VHD files that are being used, and on your machine’s hardware capabilities.
As you can see, exporting a virtual machine is really simple. Now let’s take a look at the anatomy of the exported information, and how the import process works.
The Anatomy of a Virtual Machine
When you export a virtual machine, one of the things that Hyper-V asks you for is the export path. Whatever path you enter, Hyper-V will create a folder in that path that bears the name of the virtual machine that you are exporting. For instance, when I exported my virtual machine, I used C:\R2 as the path, and Hyper-V created a new folder named R2. Now my virtual machine resides in a folder named C:\R2\R2, as shown in Figure C.
Hyper-V creates a folder in the destination path that bears the name of the virtual server that you are exporting.
If you look at the figure, you will notice that within the folder that Hyper-V creates are three sub folders. There is also an XML file named Config.xml.
The Snapshots Folder
The Snapshots folder is used as a repository for snapshots of the virtual machine. This folder contains three elements. First, there is a subfolder that bears the virtual machine’s GUID. If no snapshots exist, the folder will still be present, but it will be empty. If snapshots do exist, then this folder will contain the diffing data for the virtual hard disks.
The snapshots folder may also contain a subfolder for each snapshot. This folder bears the name of the individual snapshot ID. In addition, there will be an export file (a .EXP file) for each individual snapshot.
The Virtual Hard Disks Folder
As the name implies, the Virtual Hard Disks folder stores the .VHD files (virtual hard drive files) used by the virtual machine. You can see an example of this in Figure D.
The Virtual Hard Disks folder contains the .VHD files for the virtual server.
The Virtual Machines Folder
At a minimum, the Virtual Machines folder will contain a file named after the virtual machine’s GUID, but with an .EXP extension. This file is the virtual machine export file. It retains the virtual machine’s settings during the export process.
If the virtual machine was in a saved state during the export process, then the Virtual Machines folder will contain a sub folder, which will store two saved state files. If the machine was not in a saved state at the time of the export, then the sub folder may exist, but it will be empty.
Importing a Virtual Machine
The import and export process is used primarily as a means for moving virtual machines from one host server to another. Therefore, the first step in the import process is to copy the export folder and all of its sub folders to the desired host server. After doing so, open the Hyper-V Manager and click the Import Virtual Machine link. You should now be prompted to enter the virtual machine’s path.
Although this seems simple enough, there are two very important There are two important things that you need to know about the import process. First, it is up to you to copy the virtual machine files to the location from which you want to use them. When you import the virtual machine, it’s physical location on the host server becomes permanent, and moving the virtual machine is no longer an option. It is therefore important to place the virtual machine files on the desired volume before you import it.
The other thing that you need to know is that when you import the virtual machine, the .EXP file and the CONFIG.XML files will be deleted. These files are replaced with a new CONFIG.XML file. What this means to you is that because the .EXP file is gone, the virtual machine cannot be imported again (unless you export it again). If you want to use the virtual machine as a template or as an image that you can quickly restore, then it is important to work only from a copy of your exported files so that the original remains untouched.
The process of importing and exporting virtual machines isn’t all that difficult, but by following these tips, hopefully you’ll save yourself from a few of the most common pitfalls related to duplicate virtual machines or the imported machine’s location.