close x

Howto bundle an EC2 Amazon image (not EBS)

Ok, I’m sure that you build an image (not EBS) on Amazon EC2 and after all you wanted to save it…how?

On the Ami in Amazon EC2 lets make the following.

1- lets going to install Amazon EC2 API:

perl -pi -e ‘s%(universe)$%$1 multiverse%’ /etc/apt/sources.list

apt-get update

apt-get install ec2-api-tools ec2-ami-tools

2- We need to set some environment variables, this variables are pointing to a directory where the certeficates are stored, we need the key that you downloaded to access your images, and the x.509 certificate.

export EC2_PRIVATE_KEY=/mnt/pk-K5AHxxxxxxxxxxxxxxxxxx.pem

export EC2_CERT=/mnt/cert-K5Axxxxxxxxxxxxxxxxxx.pem

export EC2_ACCNO=9xxx-6xxx-7xxx

export ACCESS_KEY=AKIAJxxxxxxxxxx

export SECRET_KEY=2h/xxxxxxxxxxxxxNKIxxj/xxxx

3.- Bundling the AMI: This step will create an image and break it into different part 10MB each and encrypt them.(note:if it is an AMD64 system replace i386 by x86_64)

ec2-bundle-vol -d /mnt -k $EC2_PRIVATE_KEY -c $EC2_CERT -u $EC2_ACCNO -r i386

4- Create a bucket on S3: In this bucket our newly created AMI will be saved

5- Upload AMI to S3:

ec2-upload-bundle -b YOUR-S3-BUCKET -m /mnt/image.manifest.xml -a $ACCESS_KEY -s $SECRET_KEY

6- Register the AMI: Your image must be registered with Amazon EC2, so Amazon can locate it and run instances based on it. In this process your newly created AMI will get unique AMI Id:

ec2-register –K $EC2_PRIVATE_KEY –C $EC2_CERT YOUR-S3-BUCKET/image.manifest.xml –region eu-west-1

Refrences:

http://patodirahul.blogspot.com/2011/03/create-ami.html

http://alestic.com/2009/06/ec2-ami-bundle

http://www.hennepintech.edu/techservices/pages/590

Cloud Computing0 comments

Leave a Reply