Skip to content

Creation of an Ubuntu 12.04 foundation AMI

kvick edited this page Mar 9, 2013 · 6 revisions

Purpose

Provide a method for creating a foundation image suitable for amination that doesn't depend on publicly released AMIs. We're using Ubuntu cloud-images but this procedure should work on anything that you can get an image for.

Setup

Overview

  • We're going to launch an EC2 instance so that we can create and manipulate EC2 volumes and AMIs
  • Install chef-solo and a Chef recipe to get our instance configured to run ec2-api-tools and provide some scripts
  • We'll use the ec2-api-tools to manage our EC2 resources. IAM credentials make this simpler as tools such as ec2-api-tools already know how to pull the proper credentials from the instance meta-data
  • Create an EBS volume, dd an image to it, umount, snapshot and register an AMI from the snapshot
  • This AMI is now our foundation AMI that we can run aminate on to layer the components of a Base AMI on top of
  • The Base AMI will be used later by other aminator jobs to build Application AMIs which layer specific application components on top of the Base AMI

Prerequisites

  • AWS account
  • IAM profile with proper EC2 credentials (e.g. Power User)

Steps

Run an instance we can use to build a foundation image

  • First, we need to be running in EC2 so that we can (easily) manipulate EC2 resources
1 + ![blah ](https://netflix.box.com/s/jh7sll61z1ujuni8fpdj) + blah blah launch instance + install chef solo, download our tar.gz with chef recipe and configs, run chef, confirm output + curl cloud-image file from cloud-image. untar precise-image + dd an image to it, umount, snapshot and register an AMI from the snapshot

Example

ubuntu@ip-10-252-62-202:~$ ec2-create-volume --region us-west-2 -s 10 -z us-west-2a
VOLUME  vol-4fe1de76    10              us-west-2a      creating        2013-03-07T23:00:50+0000 standard

ubuntu@ip-10-252-62-202:~$ ec2-attach-volume --region us-west-2 vol-4fe1de76 -i i-54723f66 -d
/dev/xvdf
ATTACHMENT      vol-4fe1de76    i-54723f66      /dev/xvdf       attaching 2013-03-07T23:33:49+0000

ubuntu@ip-10-252-62-202:~$ time sudo dd if=precise-server-cloudimg-amd64.img of=/dev/xvdf
conv=sync,noerror bs=1M
1408+0 records in
1408+0 records out
1476395008 bytes (1.5 GB) copied, 81.6868 s, 18.1 MB/s

real    1m21.818s
user    0m0.140s
sys     0m3.040s


ec2-detach-volume --region us-west-2 vol-4fe1de76ATTACHMENT      vol-4fe1de76    i-54723f66      /dev/xvdf       detaching 2013-03-07T23:33:49+0000
ubuntu@ip-10-252-62-202:~$ ec2addsnap --region us-west-2 vol-4fe1de76
SNAPSHOT        snap-d3656bea   vol-4fe1de76    pending 2013-03-08T00:11:29+0000 471318250990    10
ubuntu@ip-10-252-62-202:~$ ec2reg --region us-west-2 -n "ubuntu-foundation" -d "12.04.2" -a  x86_64-b /dev/sda1=snap-d3656bea::true --kernel aki-fa37bacaIMAGE   ami-285bce18

ubuntu@ip-10-252-62-202:~$ ec2-run-instances --region us-west-2 ami-285bce18 -k kvick-foundation -t
t1.micro -g kvick-default --kernel aki-fc37bacc
RESERVATION     r-a40db096      471318250990    kvick-default
INSTANCE        i-06b5fa34      ami-285bce18                    pending kvick-foundation        0

TODO

  • Create a tarball of our chef recipe and host it somewhere (box?) so we don't need to do the zip install step
  • Test with CentOS
  • Install aminate on our runing instance to create a base AMI using
Clone this wiki locally