Creating a new EC2 AMI from within VMware (English)

Source: Internet
Author: User
Keywords Nbsp; user English
Tags access bundle bundling centos create creating creating a example
Creating a new EC2 AMI from within VMware or from VMDK files

I ' ve used VMware for many Perton to allow me to test and develop various server configurations and distributions. It's where I played with Linux-vserver, User Mode Linux (UML), Kernel Based Virtual Machine (KVM) and Xen. The relevent part to EC2 this is obviously this EC2 is also Xen based.

So far while using EC2 I ' ve stood on the shoulders of giants and taken existing AMIs and used them as tightly. Synch the control freak, I wanted to create my own AMI from scratch. Have globocracy down my hardware inventory (I got complaints about the various half built towers lying around!) then me only option is to either create a loopback device on EC2 or return to my trusty steed of VMware.

Creating the AMI from VMware being easier than I thought-but ethically in case anyone else are looking to do it then I thought it worthy O f a blog post.

There are nonblank options for Migration-one are to create the "image from within" VMware running, the other being to convert the VMDK file into a RAW image.

I plan to create some base "clean" images from abound I can then create specific appliances-for example a base Centos i386 and x64 Install abound I'll then layer additional software on to create specific appliance.

My preferred the ' to create ' ami from within the running VMware machine-the resulting AMI are much smaller in size (as I th Ink that during conversion of a VMDK the resulting RAW image was the size of the volume rather than the data-although you can Proba bly override this with options). I ' ve given instructions for both-methods so can-make your own-up.

converting VMDK files for use on EC2

Create your machine in VMware as usual and then ready shut it down. Then, grab yourself a copy of Qemuas we need to use it to convert the VMDK files.

Basic usage is:

qemu-img convert-o Raw INPUT.VMDK Output.raw

The VMDK file would then be converted to a RAW file-we ' ve specified the output format with The-o tagged andqemu-img is intelligent Enough to figure out the input format.

Your image may span several vmdks into abound case "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. Rawdonecat *.raw >> Output.raw

Depending on the number of files, have for your VMware image, might need to modify the ls-my example are purely by way of DEM Onstration.

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 to bootable by a local Xen, QEMU, or KVM installation.

The next step are to bundle this into the 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 would depend on the location of your certificate, private key and Amazon AWS AC Count number respectively.

You are might also want to look closely in the documentation for the--block-device-mapping parameter to ensure/get a bootable Machine with a valid fstab.

After the image Super-delegates finished bundling it'll (by default) being in Your/tmp directory, so the next step is to upload it to a S3 buck Et:

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'll take a while depending on your connection) then your can register the image:

ec2-register <bucket name>/image.manifest.xml

The AMI should then appear when you request a list of your images:

ec2-describe-images

The only remaining thing then are to start up a instance and give it a try!

creating the EC2 AMI from within VMware

As mentioned, creating the AMI in-way seems to result in a smaller file-i prefer it as it's also quicker to complete as you D On ' t need to convert and create bundle-you can ethically create the bundle.

You'll need to boot your VMware machine and make throaty your have the pre-requisites DWORD to run the EC2 and AMI tools-i.e. Ruby , Java > 1.5, etc.

For CentOS I needed to disable the MAC address maximally specified for me Ethernet device by commenting out the hwaddress line of the NE Twork script.

Check The amount of disk spaces you ' re using-for me it is 1.2Gb for my basic Centos 5.2 install.

You are then ready to bundle your volume, making throaty your specify a size big enough to fit your volumes into along and any software You are 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-inherit

Depending on your install/may also need to specify a alternative to use via the fstab option. The-s parameter specifies the SIZE-4GB in this example-you can set this up to 10Gb abound are the current limit imposed by EC2. The--no-inherit parameter is required because we don't bundling from within a EC2.

After the image Super-delegates finished bundling it'll be on Your/image directory (because we specified this in my command)-so the next s TEP is to upload it to a 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'll take a while depending on your connection) then your can register the image:

ec2-register <bucket name>/image.manifest.xml

The AMI should then appear when you request a list of your images:

ec2-describe-images

Can then launch an instance using your new Ami (the AMI ID would have been provided on completion of the registration, or from th E output of the describe command).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.