[ubuntu-cloud] Ubuntu AMI creation

Scott Moser smoser at ubuntu.com
Mon Apr 9 15:01:10 UTC 2012


On Fri, 6 Apr 2012, Devon Strawn wrote:

> Hi Scott,
>
> I'm trying to create a custom Ubuntu AMI that's as "official" and
> compatible with EC2 as possible.  The core problem is that it's difficult
> to determine the most up-to-date information on AMI creation.  There are
> plenty of blog posts & wikis, but the bulk of that knowledge is out-of-date
> or incorrect, due to the rapid pace of change in recent years.
>
> Questions:
>
>    - What's the most straightforward way to create a custom AMI from *install
>    media* (.ISOs) on a local machine / VM ?
>    - What's the most straightforward way to create a custom AMI from *an
>    existing Ubuntu VM disk image* (e.g., from .ISOs) on a local machine /
>    VM ?
>    - How is this process different when targeting EBS vs. S3 storage?
>    - How does cloud-init play into these scenarios? Does cloud-init require
>    special handling when building the AMI vs. first-run and subsequent runs on
>    EC2?
>    - I'd like to run these same AMIs on a local KVM host -- does this
>    require additional steps (I read somewhere that EC2 is Xen-based), or
>    should this just work?

   Our images "just work" under kvm or Xen (which EC2 is xen).  To run
them locally you need to provide them with some sort of meta-data so they
don't hang around looking for the EC2 metadata service.
   http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/doc/nocloud/README
   documents how to do that with 12.04.

   https://help.ubuntu.com/community/UEC/Images#Ubuntu_Cloud_Guest_images_on_Local_Hypervisor_Natty_onward
   documents how to do it on 11.04 and 11.10.

>    - What's the status of EC2 support for vmbuilder? The tool seems to
>    still accept the "-ec2" parameter(s), but it's reported that this has been
>    broken since Lucid and the
> bug<https://bugs.launchpad.net/ubuntu/+source/vm-builder/+bug/576501>is
> now "won't fix" - is this indeed the case?

   Well, our build process uses vm-builder for releases up to and
including 11.04.  Then we moved to live-build.  There is a fair aount of
information at https://wiki.ubuntu.com/UbuntuCloud/Images/Publishing .
   I suspect that vm-builder should mostly work for in the manner in which
we use it for 12.04 even.

>    - Is there a basic "theory" (however primitive) that helps when thinking
>    about creating AMIs -- at various levels of the stack?

   My general advice is to avoid doing it.  I really see very little to
gain and a lot of hair to be pulled out by trying to optimize the Ubuntu
base image.

   Take our images on http://cloud-images.ubuntu.com , download them, do
the small (or large) modifications you wish, and then upload them.  This
can be automated, and with 12.04, its reasonably straight forward (admittedly
missing documentation).  The 'vdenv' which is used for QA in MAAS has a
script that re-purposes a cloud-image via cloud-init.  See 'build' at
   http://bazaar.launchpad.net/~maas-maintainers/maas/trunk/files/head:/vdenv/zimmer-build/

   For ebs, I'd suggest building a one-off EBS ami by scripting the whole
thing, feeding cloud-init some data that would result in it doing your
modification process, and then shutting down.  Then when instance is
shutdown, you snapshot and register.

> And a meta-question: how should I go about finding answers to questions
> like these for myself?

   There is no really good source of such data.  Much of it is general
understanding of linux image makeup and boot, much of it is guesswork.
There has been more than a small amount of hair pulling when debugging
issues on EC2.
   My goal in building the ubuntu images is to save you from having to
care about such things.

> In other words, what's the process for figuring out solutions to these
> kinds of problems in the Ubuntu ecosystem?

   We really could stand for better documentation and even tools on how to
take an ubuntu image and rebundle or create your own ebs root instance
based off one from ubuntu.  Your participation in creating such
documentation would be great.

>
> Thanks,
>    Devon



More information about the Ubuntu-cloud mailing list