Importing a Virtual Machine into Amazon EC2 (Part 6)

If you would like to be notified when Brien Posey releases the next part in this article series please sign up to our InsideAWS.com Real-Time Article Update newsletter.

If you would like to read the other parts in this article series please go to:

Introduction

So far in this article series, I have spent a lot of time talking about how to prepare to migrate a VM from your local datacenter to Amazon EC2. In this article, I want to begin talking about the actual migration process. This migration process consists of two primary tasks – exporting the VM from your on premise hypervisor and importing the VM into the Amazon cloud.

Exporting the VM

Before you will be able to import a VM into the Amazon cloud, you will need to export it from your local hypervisor. Exporting a VM is a science in and of itself. The technique used to export a VM will vary considerably depending on which hypervisor is currently hosting the VM, the hypervisor version, and the VM’s configuration. For the sake of illustration, I will spend a bit of time talking about how you would export a VM from Microsoft Hyper-V. I am going to assume that the VM has already been prepared for export and that it meets all of the requirements that were discussed earlier in this series.

The first step in exporting a Hyper-V VM is to choose an export location. You will need to pick a location that has enough free space to accommodate the VM and its various components. Once you have settled on a storage location, create a folder that will be used to store the exported VM. For instance, you might place the exported VM in F:\Export.

The actual export process is simple. Assuming that the VM is powered off, simply open Hyper-V Manager, right click on the VM and choose the Export command from the shortcut menu. When you do, the Hyper-V Manager will display a dialog box asking for the path within which you wish to store the exported VM. Enter the path to the folder that you just created and click Export, as shown in Figure A.

Image
Figure A: Enter the name of the path where the exported VM should be stored and then click the Export button.

Although this is technically all that is required in order to export a Hyper-V virtual machine, it is a good idea to familiarize yourself with what is going on behind the scenes.

The first thing that you need to know is that in the case of Windows Server 2012 R2 Hyper-V, the export process does not destroy the VM. The virtual machine remains intact and completely functional. When you export the virtual machine, Hyper-V is essentially creating an off-line, detached copy of the virtual machine. In other words, the folder that you specify during the export process contains a full copy of the virtual machine, but that virtual machine copy is not linked to the Hyper-V Manager. That means that you are not going to be able to boot the exported copy without first importing it.

When you complete the export process, Hyper-V creates a folder in the specified export location. This folder bears the name of the exported virtual machine. For example, while writing this article I exported a VM named Windows Server 2016 Preview 2B to a folder named F:\Export. The exported VM was consequently placed into F:\Export\Windows Server 2016 Preview 2B\.

The export process creates three sub-folders beneath the path discussed in the previous paragraph. These folders include: Snapshots, Virtual Hard Disks, and Virtual Machines. You can see what this folder structure looks like in Figure B.

Image
Figure B: This is the folder structure that is created when you export a Hyper-V virtual machine.

As you would probably expect, the Snapshots folder contains any virtual machine snapshots that might exist. In spite of the folder name, Microsoft refers to snapshots as checkpoints.

Equally intuitive is the Virtual Hard Disks folder. As the name implies, this folder contains the virtual hard disks that are used by the virtual machine.

Finally, there is the Virtual Machines folder. This folder contains the configuration data for the virtual machine. Normally, this folder contains a single file that uses an .EXP extension. This is the file that contains all of the configuration data for the virtual machine. It is worth noting that some versions of Hyper-V delete this file as a part of the import process in order to prevent the exported virtual machine from being imported more than once.

Even though the folder structure that I have just discussed is unique to virtual machines that have been exported from Microsoft Hyper-V, I wanted to go ahead and spend a little bit of time talking about the export process in the resulting folder structure because it is at least somewhat representational of what you can expect from other hypervisors.

While I am on the subject of Microsoft Hyper-V, I need to take a few minutes and talk about some of the virtual machine requirements. Amazon is fairly picky when it comes to the virtual machine import process. As I mentioned back in Part four of this article series, there is a whole laundry list of things that have to be done in order to prepare a virtual machine to be imported into the Amazon cloud. The preparation tasks that I discussed in previous articles apply to any virtual machine that you are planning to import into the Amazon cloud. However, there are sometimes additional requirements depending on the import method that you will be using.

If you think back to the beginning of this article series, you will recall that we installed the Amazon Command Line Interface. If you are going to be using the Amazon Command Line Interface to import the virtual machine then there are some prerequisites that you will have to meet before you begin the import process. You can find the full list of requirements here but I wanted to wrap up this article by talking about a few of the more important ones.

With that said, you will need to pay attention to the virtual hard disk format. In the case of Hyper-V virtual machines, Amazon requires dynamic virtual hard disks in VHD format. VHDX images are not supported.

Amazon also has some requirements for the volumes residing on the virtual hard disks. Specifically, Windows virtual machines must use MBR partition volumes and those volumes must be formatted using the NTFS file system. GPT partition volumes are not supported, nor are the FAT, FAT-32, or ReFS file systems. Amazon also recommends that the virtual hard disk contains at least 250 MB of free space. The reason for this is that Amazon injects drivers and possibly other software into the virtual hard disks, so the virtual hard disks need to have enough free space to accommodate these components.

You also need to be aware of the fact that Amazon has requirements related to the virtual machine’s network configuration. Specifically, you can only have a single virtual network adapter for each virtual machine and that network adapter must be configured to acquire an IP address from a DHCP server. Furthermore, IPv6 addresses are not supported.

Conclusion

As you can see, the virtual machine export process is easy to perform. Even so, there can be a substantial amount of work involved in getting a virtual machine ready to move to the Amazon cloud.

Now that I have shown you how to export a virtual machine, it’s time for the import process. I will walk you through the process in the next article.

If you would like to be notified when Brien Posey releases the next part in this article series please sign up to our InsideAWS.com Real-Time Article Update newsletter.

If you would like to read the other parts in this article series please go to:

Leave a Comment

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top