Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

1) Create the image file and initialize the filesystem on it (note that
I'm only making giving myself 1G of space for this install, if you think
you will need more room you should create a larger file by changing the
seek value):

Code Block
dd if=/dev/zero of=fc6-i386.img bs=1M count=1 seek=2048
/sbin/mke2fs -F -j fc6-i386.img

...

Code Block
mount -o loop fc6-i386.img /mnt mnt


 3) Create base directories and device files:

...

 
4) Create the initial fstab [file:\\
]

Code Block
cat <<EOL > /mnt/etc/fstab
/dev/sda1 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/sda2 /mnt ext3 defaults 1 2
/dev/sda3 swap swap defaults 0 0
EOL
 


5) Mount the proc under the new root filesystem so yum will work correctly:

...

10) Modify the boot script to download your SSH key and stick it in root's directory:

Code Block
cat <<EOL >> /mnt/etc/rc.local
if [ ! -d /root/.ssh ] ; then
mkdir -p /root/.ssh
chmod 700 /root/.ssh
fi
# Fetch public key using HTTP
curl http://169.254.169.254/1.0//meta-data/public-keys/0/openssl >
/tmp/my-key
if [ $? -eq 0 ] ; then
cat /tmp/my-key >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
rm /tmp/my-key
fi
# or fetch public key using the file in the ephemeral store:
if [ -e /mnt/openssh_id.pub ] ; then
cat /mnt/openssh_id.pub >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
fi
EOL

...

Code Block
cat <<EOL >> /mnt/etc/ssh/sshd_config
UseDNS no
PermitRootLogin without-password
EOL EOL


12) Create the networking scripts:

Code Block
cat <<EOL > /mnt/etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
EOL

cat <<EOL > /mnt/etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
DEVICE=eth0
BOOTPROTO=dhcp
EOL

...

You have now created your very own bootable AMI. If you want to fiddle
with it from this point you may continue to use the yum command as in
the above examples or you can also remount the filesystem and chroot to
it using a command like this:

Code Block
mount -o loop fc6-i386.img /mnt
mount -t proc none /mnt/proc
chroot /mnt /bin/sh

...

The next step is to get the AMI to S3 so that it can be booted.

Bundling an AMI

 


A root file system image needs to be bundled as an AMI in order to be
used with the Amazon EC2 service. The bundling process first compresses
the image to minimize bandwidth usage and storage requirements. The
compressed image is then encrypted and signed to ensure confidentiality
of the data, and authentication against the creator. The encrypted image
is finally split into manageable parts for upload. A manifest file is
created containing a list of the image parts with their checksums. This
chapter provides an overview of the AMI tools that automate this process
and some examples of their use.

...

1. ec2-bundle-image bundles an existing AMI
2. ec2-bundle-vol creates an AMI from an existing machine or installed volume
3. ec2-upload-bundle uploads a bundled AMI to S3 storage

 

Installing the AMI Tools


The AMI tools are packaged as an RPM suitable for running on Fedora Core
3/4 with Ruby 1.8.2 (or greater) installed. On Fedora Core 4 Ruby can be
installed by following the steps below. You will need root privileges to
install the software. You can find the AMI tools RPM from our public S3
downloads bucket.

First install Ruby using the yum package manager.

#  

Code Block

yum install ruby

Install the AMI tools RPM.#

 

Code Block

rpm -i ec2-ami-tools-x.x-xxxx.i386.rpm

 

Installation Issues

 

The AMI tools libraries install under /usr/lib/site_ruby. Ruby should
pick up this path automatically, but if you see a load error when
running one of the AMI utilities, it may be because Ruby isn't looking
there. To fix this, add /usr/lib/site_ruby to Ruby's library path, which
is set in the RUBYLIB environment variable.
Documentation

The manual describing the operation of each utility can be displayed by
invoking it with the --manual parameter. For example:

#  

Code Block

ec2-bundle-image --manual

 

Invoking a utility with the --help parameter displays a summary and list
of command line parameters. For example:

#  

Code Block

ec2-bundle-image --help

 

Using the AMI Tools in Bundling an Image

Once a machine image has been created it must be bundled as an AMI for
use with Amazon EC2, as follows. Use ec2-bundle-image to bundle an image
that you have prepared in a loopback file, as described in the previous
section.
#

Code Block

ec2-bundle-image -i my-image.img

...

 -k  private_key.pem -c

...

 certificate.pem -u 12345678

This will create the bundle files:

 

Panel

image.part.00
image.part.01
...
image.part.NN
image.manifest.xml


Uploading a Bundled AMI

 
The bundled AMI needs to be uploaded for storage in Amazon S3 before it
can be accessed by Amazon EC2. Use ec2-upload-bundle to upload the
bundled AMI that you created as described above. S3 stores data objects
in buckets, which are similar in concept to directories. Buckets must
have globally unique names. The ec2-upload-bundle utility will upload
the bundled AMI to a specified bucket. If the specified bucket does not
exist it will be created. However, if the specified bucket already
exists, and belongs to another user, then ec2-upload-bundle will fail.
#

Code Block

ec2-upload-bundle -b my-bucket -m image.manifest.xml -a

...

 my-aws-access-key-id -s my-secret-key-id

And Register as an AMI Bundle 

Code Block

ec2-register my-bucket/image.manifest.xml


now you can success fully your bundle is now ready to use







Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery