This document describes the steps necessary to migrate a VMWare virtual machine (.vmx and accompanying .vmdk) to the Amazon Web Services (AWS) cloud.
Setting up AWS Command Line Tools
There are many actions in AWS that can only be completed by using the AWS command line tools. This section describes the steps necessary to set up these tools (Evens, 2009).
Install Java
Download and install Java if you do not already have it: http://www.java.com/en/download/manual.jsp#win.
Download APIs
- EC2 Command line tools: http://aws.amazon.com/developertools/351
- Elastic Load Balancing tools: http://aws.amazon.com/developertools/2536?_encoding=UTF8&jiveRedirect=1
It is a good idea to pick somewhere to place all of your command line related items; for example: C:\AWS. Unzip both archives into this folder.
Get your AWS Certificates
- Go to https://aws-portal.amazon.com/gp/aws/securityCredentials
- Log in
- Scroll down to the X.509 section
- Create a new certificate (if one does not exist)
- Download the Private Key File (pk-.pem) and store in AWS directory
- Download the Certificate File (cert-.pem) and store in AWS directory
- KEEP THESE FILES PROTECTED – they provide access to your AWS account
Configure Environment Variables
Create a batch file in your AWS directory awsTools.bat and add the following text:
[sourcecode language=”plain”]
SET JAVA_HOME=”C:\Program Files (x86)\java\jre6″
SET EC2_PRIVATE_KEY=c:\aws\aws-pk.pem
SET EC2_CERT=c:\aws\aws-cer.pem
SET EC2_HOME=c:\aws\ec2\ec2-api-tools-1.5.2.4
SET PATH=%PATH%;%EC2_HOME%\bin
SET AWS_ELB_HOME=D:\aws\ElasticLoadBalancing-1.0.15.1
SET PATH=%PATH%;%AWS_ELB_HOME%\bin
CLS
CMD
[/sourcecode]
JAVA_HOME will need to be set to the appropriate path for your machine. Find java.exe (it will be a in a folder called bin) and set JAVA_HOME to the parent directory of bin. For example with java.exe at “C:\Program Files (x86)\java\jre6\bin\java.exe” set JAVA_HOME to “C:\Program Files (x86)\java\jre6”.
EC2_HOME and AWS_ELB_HOME both point to the folders you unzipped the APIs into.
Test Command
If you run awsTools.bat you should have a command prompt that you can run the EC2 tools from.
Type ec2-describe-regions at the command prompt
Your results should look something like the following:
REGION eu-west-1 eu-west-1.ec2.amazonaws.com
REGION us-east-1 us-east-1.ec2.amazonaws.com
If you get an error or nothing is returned, check your configuration.
Setting Up Your VMware Image
There are several changes that should be made (if needed) to your VMware image before it is converted and uploaded to AWS.
- Remove all snapshots – remove any snapshots that you may have. If you do not want to remove snapshots, create a copy of your .vmdk and create a new VMware image that points to it.
- Partition must be IDE – If you have any SCSI Devices, you should convert them to IDE. You may want to use a third party tool to do this such as Acronis.
- Uninstall VMware tools- if you have installed the VMWare tools, remove them.
- Enable Remote Desktop Access – you will want to enable remote desktop connections and make sure that they are permitted through the firewall (if enabled).
Convert VM to OVF
OVF (Open Virtual Format) is a universal virtual machine format that is used for distribution across organizations and products. You must convert your VMware image to this format so that AWS can convert it to its virtualization format. This process may take several hours depending on the size of the image.
- Download the too from: http://www.vmware.com/resources/techresources/1013
- Open a command line with administrator privileges
- Example Syntax:
ovftool “C:\Virtual Machines\Windows Server 2008 x64.vmx” “C:\Virtual Machines\Windows Server 2008 x64.ovf”
Import to AWS, Setup & Connect
Once the VM has been converted to OVF format, it is ready to be imported to AWS.
- Open awsTools.bat
- Get Access Key and Secret Access Key from AWS: My Account / Console > Security Credentials
- Create Import instance using ec2-import-instance
- Example Syntax:
ec2—import—instance “C:\Documents\Virtual Machines\Windows Server 2008 x64—disk1.vmdk” -f vmdk -t ml.large —a x86_64 —o XXXXXXXXXXXXXXXXXXXX —w XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX —b my_bucket - b. -o = Access Key
- c. -w = Secret Access Key
- d. -t = Instance Types (see http://aws.amazon.com/ec2/instance-types/)
- Wait until the Instance is uploaded and converted
- Use ec2-describe-conversion-tasks to check status
- Start Instance
- Open up RDP port (3389) using the AWS Security Group inbound rules
- Obtain an Elastic IP from AWS
- Under Network Interfaces in AWS, assign Elastic IP to the network interface that belongs to the instance
- Connect via RDP using Elastic IP address
References
Evens, S. (May 19, 2009). Setting up EC2 command line tools on Windows. Retrieved March 20, 2012 from http://sevans.info/2009/05/19/setting-up-ec2-command-line-tools-on-windows/.
matiasimc. (June 21, 2011). Re: VMWare Workstation VM import Windows 2008 R2 failing. Retrieved March 29, 2012, from https://forums.aws.amazon.com/thread.jspa?threadID=58171.
VMware. (May 21, 20009). VMware OVF Tool. Retrieved March 29, 2012, from http://www.vmware.com/resources/techresources/1013.
I never knew there was so much Java setup involved with using AWS.
Great reference.
Note: if you run into weird errors such as “–waiting on stdin–“, make sure your command text is clean. Copy / paste from this post can put some hidden characters into the command. To be safe, retype the whole thing.
Thanks for comment, I had the –waiting on stdin– issue and was able to fix it with proper cut and paste
getting client error: no windows directory found. Any help would be appreciated.
At what point do you get this error? Setup? Conversion? Import?
“Partition must be IDE – If you have any SCSI Devices, you should convert them to IDE. You may want to use a third party tool to do this such as Acronis.”
Can you give me some detail? When I play with vmware workstation 10,whatever IDE or SCSI it fails.It alwayze said:” Instance does not have a volume attached at root (/dev/sda1)”
Does your AWS Instance have a volume attached to it? When you select an instance and then scroll down in the description tab. You should see something like:
Root device type: ebs
Root device: /dev/sda1
Block devices: /dev/sda1
If not, you probably do not have a volume attached; so it has no place to put the image.
Well,I’m glad to receive from you !
The following is my all steps:
D:\>ovftool “D:/vmware/win2008r2/win2008r2.vmx” “D:/vmware/win2008r2/win2008r2.ovf”
Opening VMX source: D:/vmware/win2008r2/win2008r2.vmx
Opening OVF target: D:/vmware/win2008r2/win2008r2.ovf
Writing OVF package: D:/vmware/win2008r2\win2008r2.ovf
Transfer Completed
Completed successfully
D:\>ec2-import-instance “D:/vmware/win2008r2/win2008r2-disk1.vmdk” -f VMDK -p Windows -a x86_64 -t m1.small –region ap-southeast-1 -b vmfile
When it is uploaded completely, I create a volume in the aws console and attach to it.Then description tab as following:
Root device type
ebs
Root device
/dev/sda1
Block devices
/dev/sda1
Then I check the task status,following is the result:
D:\>ec2-describe-conversion-tasks –region ap-southeast-1 import-i-fgmvkz4k
TaskType IMPORTINSTANCE TaskId import-i-fgmvkz4k ExpirationTime
2014-04-09T06:48:04Z Status active StatusMessage Progress: 53% InstanceID i-d3ad68fb
DISKIMAGE DiskImageFormat VMDK DiskImageSize 4350580224 VolumeId
vol-ddbcbfd2 VolumeSize 40 AvailabilityZone ap-southeast-1a ApproximateBytesConverted 4350575488 Status completed
D:\>ec2-describe-conversion-tasks –region ap-southeast-1 import-i-fgmvkz4k
TaskType IMPORTINSTANCE TaskId import-i-fgmvkz4k ExpirationTime
2014-04-09T06:48:04Z Status cancelled StatusMessage FirstBootFailure: This import request failed because the instance failed to boot and establish network connectivity. InstanceID i-d3ad68fb
DISKIMAGE DiskImageFormat VMDK DiskImageSize 4350580224 VolumeId
vol-ddbcbfd2 VolumeSize 40 AvailabilityZone ap-southeast-1a ApproximateBytesConverted 4350575488 Status completed
Could you give me some adivces to fix it?
Good afternoon, it happens to me the same… I don’t know what is happening. Did you fix it?
I get the same issue. Did someone manage to fix this?
Thank you!
Great post. The steps you have outlined for migration are quite detailed and accurate.
Have you considered simply uploading your vmdks and running them as-is in AWS (without converting the VM or editing the networking)? You can actually do that with Ravello ‘s nested virtualization Saas http://www.ravellosystems.com .
Same here. Stuck @ 53%.
Did you resolve it?
Thnx