Browsing the archives for the EC2 tag.

Create Amazon EC2 AMI

Examples

aws

Creating an Amazon EC2 AMI from an existing image seems like a challenging process however, it is actually fairly simple. Before looking at the steps to create the image, first have the following AWS information/files handy:

  • Access key
  • Secret Key
  • Account Number
  • Private key (e.g., pk-37BKCPZ2AVHVSYBK2WZXUQ9D4GQZEB4Q.pem)
  • Certificate (e.g., cert-38BKCPZ1BOHVSYBK4WZXUQ4D4GQZEB2Q.pem)

Next, login to your instance and make sure you have the Amazon AMI and EC2 API tools installed and available in your PATH. Also, upload your private key and certificate to the server.

Now you are ready to create your image file. First create a directory to store this image in.

E.g.

mkdir /mnt/ami

The actual AMI bundle is created by running:

ec2-bundle-vol -d /mnt/ami -k YOUR_PRIVATE_KEY -c YOUR_CERTIFICATE -u YOUR_ACCOUNT_NUMBER

note: The account number should not contain any dashes (‘-’).

Creating the bundle takes a few minutes. After the bundle has been created, it is time to upload it to S3. This is done by running:

ec2-upload-bundle -b YOUR_BUNDLE_NAME -m /mnt/ami/image.manifest.xml -a YOUR_ACCESS_KEY -s YOUR_SECRET_KEY

This walks through the files generated by the bundle command and inserts them into S3.

After your files have been uploaded, it is time to register the AMI using the following command:

ec2-register YOUR_BUNDLE_NAME/image.manifest.xml

The result of running this command is your AMI id.

E.g.

ami-323FEA

Finally, your AMI has been created, uploaded and registered and you are able to launch a new instance of your AMI.

If you need more help, there is a good video available from an Amazon employee. Additionally, take a look at the Amazon docs on the subject.

No Comments

Create Amazon EBS

Examples, Tools

aws

The Amazon Web Services blog has a good post on how to setup an EBS volume using ElasticFox:

Amazon EBS (Elastic Block Store) – Bring Us Your Data

I do not see a way to schedule snapshots through the UI so, you may have to write a script to accomplish this feat.

Once you have created your EBS volume you still have to mount the new device. First add the following line to /etc/fstab:

/dev/YOUR_DEVICE_NAME  /data  ext3  defaults 0 0

E.g.

/dev/sde  /data  ext3  defaults 0 0

Next, you need to format the device. This is accomplished by executing:

mkfs.ext3 /dev/YOUR_DEVICE_NAME

E.g.

mkfs.ext3 /dev/sde

This post assumes you are using the ext3 filesystem. Next, you need to mount the device. This is done by issuing:

mount -t ext3 /dev/YOUR_DEVICE_NAME /DIRECTORY_TO_MOUNT_IN

E.g.

mount -t ext3 /dev/sde /data

After you mount the device you should be good to go. If possible, reboot your instance to make sure the process mounted properly on a restart.

1 Comment