There are two options for migration - one is to create the image from within the running VMware machine, the other is to convert the VMDK file into a RAW image.
I plan to create some base 'clean' images from which I can then create specific appliances - for example a base Centos i386 and x64 install which I will then layer additional software on to create specific appliance images.
My preferred method is to create the AMI from within the running VMware machine - the resulting AMI is much smaller in size (as I think that during conversion of a VMDK the resulting RAW image is the size of the volume rather than the data - although you can probably override this with options). I've given instructions for both methods so you can make your own mind up.
Converting VMDK files for use on EC2
Create your machine in VMware as usual and when ready shut it down. Then, grab yourself a copy of QEMU as we need to use it to convert the VMDK files.
Basic usage is:
qemu-img convert -O raw input.vmdk output.rawThe VMDK file will then be converted into a RAW file - we've specified the output format with the -O tag and qemu-img is intelligent enough to figure out the input format.
Your image may span several VMDKs in which case you'll need to run a simple shell loop, for example:
for file in `ls *[0-9].vmdk`; do qemu-img convert -O raw $file $file.raw done cat *.raw >> output.raw
Depending on the number of files you have for your VMware image you might need to modify the ls - my example is purely by way of demonstration.
Either way, you should now have your VMware disk image in RAW format in the file output.raw. Given this is a RAW image it should also be bootable by a local Xen, QEMU or KVM installation.
The next step is to bundle this into an AMI using ec2-bundle-image:
ec2-bundle-image -i output.raw -r x86_64 -c ~/.amazon/cert.pem -k ~/.amazon/pk.pem --user <user id>The exact values for the -c, -k and --user parameters will depend on the location of your certificate, private key and Amazon AWS account number respectively.
You might also want to look closely at the documentation for the --block-device-mapping parameter to ensure you get a bootable machine with a valid fstab.
After the image has finished bundling it will (by default) be in your /tmp directory, so the next step is to upload it to an S3 bucket:
ec2-upload-bundle -b <bucket name> -m /tmp/image.manifest.xml -a <access id> -s <secret access id>With the bundled image in S3 (it will take a while depending on your connection) then you can register the image:
ec2-register <bucket name>/image.manifest.xmlThe AMI should then appear when you request a list of your images:
ec2-describe-imagesThe only remaining thing then is to start up an instance and give it a try!
Creating the EC2 AMI from within VMware
As mentioned, creating the AMI in this way seems to result in a smaller file - I prefer it as it's also quicker to complete as you don't need to convert and create bundle - you can just create the bundle.
You'll need to boot your VMware machine and make sure you have the pre-requisites installed to run the EC2 and AMI tools - i.e. ruby, java > 1.5, etc.
For CentOS I needed to disable the MAC address being specified for my Ethernet device by commenting out the HWADDRESS line of the network script.
Check the amount of disk space you're using - for me it was 1.2Gb for my basic Centos 5.2 install.
You're then ready to bundle your volume, making sure you specify a size big enough to fit your volumes into along with any software you might want to install in future:
ec2-bundle-vol -c ~/.amazon/cert.pem -k ~/.amazon/pk.pem --user <user id> -d /image -e /image -r x86_64 -s 4096 --no-inheritDepending on your install you may also need to specify an alternative fstab to use via the --fstab option. The -s parameter specifies the size - 4Gb in this example - you can set this up to 10Gb which is the current limit imposed by EC2. The --no-inherit parameter is required because we're not bundling from within an EC2 instance.
After the image has finished bundling it will be in your /image directory (because we specified this in our command) - so the next step is to upload it to an S3 bucket:
ec2-upload-bundle -b <bucket name> -m /image/image.manifest.xml -a <access id> -s <secret access id>With the bundled image in S3 (it will take a while depending on your connection) then you can register the image:
ec2-register <bucket name>/image.manifest.xmlThe AMI should then appear when you request a list of your images:
ec2-describe-imagesYou can then launch an instance using your new AMI (the AMI id will have been provided on completion of the registration, or from the output of the describe command).


38 comments
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Nikunj
September 24th, 2008 @ 12:53 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
September 27th, 2008 @ 21:37 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by vinchu
October 1st, 2008 @ 11:15 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Nikunj
October 1st, 2008 @ 13:20 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
October 1st, 2008 @ 16:50 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Shiju V.Joseph
December 22nd, 2008 @ 06:22 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
December 23rd, 2008 @ 22:00 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Tony S
January 5th, 2009 @ 05:16 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Tony S
January 5th, 2009 @ 19:23 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
January 7th, 2009 @ 22:31 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Barry
March 19th, 2009 @ 04:10 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
March 19th, 2009 @ 10:18 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by nanao
April 28th, 2009 @ 00:00 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
April 28th, 2009 @ 14:09 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by weput
May 6th, 2009 @ 18:31 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
May 6th, 2009 @ 21:02 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Doc Rice
May 20th, 2009 @ 10:04 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
May 20th, 2009 @ 15:57 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Zee
June 22nd, 2009 @ 14:06 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
June 22nd, 2009 @ 21:20 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Hugo Troche
August 3rd, 2009 @ 20:43 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
August 4th, 2009 @ 01:03 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by akabdog
August 8th, 2009 @ 00:49 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by dipopo
August 8th, 2009 @ 16:31 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Rob Ristroph
August 31st, 2009 @ 16:05 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by randy
September 7th, 2009 @ 06:47 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Diego
September 14th, 2009 @ 18:10 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by abhi
October 27th, 2009 @ 16:44 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Jeremy Cothran
November 11th, 2009 @ 16:33 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by jhonn
November 12th, 2009 @ 10:32 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Chris Anderton
November 16th, 2009 @ 16:03 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Jeremy Cothran
November 20th, 2009 @ 15:25 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by JT
January 5th, 2010 @ 18:59 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by jm
January 15th, 2010 @ 20:38 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by David
March 9th, 2010 @ 08:03 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by rajkumar
May 19th, 2010 @ 11:24 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Lija
October 5th, 2010 @ 11:25 – permalink
Comment on Creating a new EC2 AMI from within VMware or from VMDK files by Ashraf Khalid
December 10th, 2010 @ 14:07 – permalink
Leave a reply
You can use Markdown in your comment as well as plain HTML. You can use
<filter:jscode lang="ruby">and</filter:jscode>tags to surround code blocks (supported languages are css, html, javascript and ruby). Your email address will not be published.If your comment doesn’t appear immediately after posting it could have been marked as spam. Don’t worry: we regularly check for and approve incorrectly filtered comments so you shouldn’t have to wait too long for it to be shown.