Posts Tagged ‘aws’

Converting an AMI to an AMI that boots off of EBS

December 8, 2010

So I wanted to create an AMI that had some permanency (e.g. if I run “yum -y update” the system actually is updated when I reboot it next). Specifically I wanted to take the Fedora 14 AMI from https://fedoraproject.org/wiki/Cloud_SIG/EC2_Images, install some software on it and make it semi permanent (so I could use it as needed).

To do this you will need an EBS backed AMI. There are two ways to store an AMI image, in S3 or in EBS. S3 is a simple bit bucket and the AMI storage protocol basically boils down to “compress the disk image and cut it up into chunks, store the chunks and a manifest file in S3” so when you start an AMI it gets the manifest then downloads the appropriate chunks of data from S3, creates a disk image and fires it up. EBS actually presents like a normal disk, and changes made to an EBS volume actually change the EBS volume, so you get some permanency.

However if you terminate the instance it will still go bye-bye and any changes you made since you initially loaded it from the EBS volume it was originally created from will be gone. In order to update the AMI you will simply need to halt the running instance and take a snapshot of it, and then convert that snapshot into an AMI instance (and ideally include a version number in the name or description):

ec2-register -snapshot snap-SOMESNAP -description “A description” -name “A name 1.0” [-kernel aki-something] [-ramdisk ari-something]

For complete instructions on turning a running AMI into an EBS backed AMI please see:

http://webkist.wordpress.com/2010/03/16/creating-an-amazon-ec2-ebs-ami-from-a-running-instance/

But the synopsis is: run a AMI instance, create and mount an EBS volume on it, format the EBS as EXT3/EXT4, mount it and then rsync (use -a and -x) / to the mount point, create some devices like console so you can login:

# MAKEDEV -d /mnt/ebs/dev -x console
# MAKEDEV -d /mnt/ebs/dev -x zero
# MAKEDEV -d /mnt/ebs/dev -x null

and make sure you disable /dev/sda2 and whatnot in /etc/fstab (since your image may not have it setup and it will go sideways).

Getting Amazon AWS EC2 API Tools working properly

December 8, 2010

a) First remove all hints of Java from your system (libgcj, openjdk, etc.). Use “whereis java” and “locate java” and “rpm -qf /some/random/thing/java” to expunge your system.

b) Install JDK from Sun/Oracle (http://www.java.com/en/download/installed.jsp?detect=jre&try=1)

c) install ruby (“yum install ruby”)

d) download EC2 API tools (http://aws.amazon.com/developertools/351?_encoding=UTF8&jiveRedirect=1) , unpack, copy the bin and libs directories into /opt/ec2/ or wherever you want

e) create and download a certificate pair from the AWS management interface

f) export stuff:

export JAVA_HOME=/usr/

export EC2_CERT=/root/cert.pem

export EC2_PRIVATE_KEY=/root/pk.pem

export EC2_HOME=/opt/ec2/