Posts Tagged ‘ami’

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, 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:

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).