Resources



Articles and Tutorials

Feature Guide: Amazon EC2 User Selectable Kernels

Click for a printer friendly version of this document Printer Friendly Save to del.icio.us
 

This guide introduces the User Selectable Kernels for Amazon EC2.

AWS Products Used: Amazon EC2
Language(s): Other
Date Published: 2008-03-27

Introduction

Amazon EC2 now allows developers to use kernels other than the default Amazon EC2 kernels with their instances.

An Amazon Kernel Image (AKI) is similar to an Amazon Machine Image (AMI). The latter is prefixed with “ami-“while the former is prefixed with “aki-“. In addition, Amazon EC2 supports Amazon RAM disk Images (ARI) which might be required by kernels and are prefixed with “ari-“.

As of this release, anyone can use alternative kernels or RAM disks with their AMIs, but the ability to create and publish kernels and ramdisks is restricted to Amazon EC2 and selected vendors.

Prerequisites

Before you begin, make sure you are using the right versions of our WSDL, API Tools, and API:

  • WSDL and API version: 2008-02-01 or later
  • API Tools: 1.3-19403 2008-02-01

Note: You can check version information using the ec2ver command.

Finding Available Kernel Images (AKIs) and RAM disks(ARIs)

We'll use the getting started image, and launch it with an alternative public kernel. Finding the AMI ID for this image is described in the Amazon Elastic Compute Cloud Getting Started Guide. At the time of writing, it is ami-2bb65342.

Finding an appropriate kernel is very similar.

ec2-describe-images -o self -o amazon 
  IMAGE    ami-25b6534c     ec2-public-images/fedora-core4-apache-mysql.manifest.xml        amazon   available       public          i386    machine
  IMAGE    ami-23b6534a     ec2-public-images/fedora-core4-apache.manifest.xml      amazon   available   public              i386    machine
  IMAGE    ami-20b65349     ec2-public-images/fedora-core4-base.manifest.xml        amazon   available   public              i386    machine
  IMAGE    ami-22b6534b     ec2-public-images/fedora-core4-mysql.manifest.xml       amazon   available   public              i386    machine
  IMAGE    ami-36ff1a5f     ec2-public-images/fedora-core6-base-x86_64.manifest.xml amazon  available    public              x86_64  machine
  IMAGE    ami-2bb65342     ec2-public-images/getting-started.manifest.xml  amazon   available       public          i386    machine
  IMAGE    aki-9b00e5f2     ec2-public-images/vmlinuz-2.6.18-xenU-ec2-v1.0.i386.aki.manifest.xml    amazon   available       private         i386     kernel
  IMAGE    aki-9800e5f1     ec2-public-images/vmlinuz-2.6.18-xenU-ec2-v1.0.x86_64.aki.manifest.xml  amazon   available       private         x86_64   kernel

This command lists your AMIs and Amazon's public AMIs, AKIs and ARIs. The output might not exactly match that shown above. Look for the lines containing image IDs starting with “aki-” or “ari-” (or use command line tools like grep to filter them out). These are kernels and RAM disks, respectively. You will need the kernel ID for the next step.

Important: The architecture of your AMI, RAM disk, and kernel must match. Even then, there is no guarantee a given combination will function correctly or boot successfully if they weren’t designed to be used together. Review the AKI’s release notes to see if it requires a RAM disk.

New Kernel

As of this release, Amazon EC2 has introduced two new kernels: aki-9b00e5f2 (32 bit) and aki-9800e5f1 (64 bit). They are the 2.6.18 Xen kernels (vmlinuz-2.6.18-xenU-ec2-v1.0).


** EC2 2.6.18 Release Notes **

This kernel version was chosen based on its use as the stock Linux kernel forming part of the Xen 3.1.0 software release.

Additional patches

  • includes vmsplice root exploit patch.
Configuration detail
  • default linux clock frequency is set to 1000HZ (CONFIG_HZ=1000), up from 100HZ.
  • Xen modules(xennet and xenblk) are statically compiled.
  • Xennet driver improved to address various packet handling issues.
  • Further configuration details are available in ec2-modules packages listed below.

Modules
http://ec2-downloads.s3.amazonaws.com/ec2-modules-2.6.18-xenU-ec2-v1.0-i686.tgz
http://ec2-downloads.s3.amazonaws.com/ec2-modules-2.6.18-xenU-ec2-v1.0-x86_64.tgz

Patch details
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=712a30e63c8066ed84385b12edbfb804f49cbc44

Running an Instance with a Different Kernel

Now that you have an AKI ID, you can launch an instance of the getting started AMI using this kernel. The following example assumes you created a keypair called gsg-keypair and that you authorized access on port 22 from the machine you are on for your default security group.

ec2-run-instances ami-2bb65342 -k  gsg-keypair –-kernel aki-9b00e5f2
  RESERVATION      r-fb6e9e92      924417782495    default
  INSTANCE i-10a64379 ami-2bb65342 pending 0  m1.small 2007-07-11T16:40:44+0000 us-east-1c aki-0924c160

After launching the instance, ssh into the instance and confirm it is running a 2.6.18 kernel using the uname command.

ssh -i  id_rsa-gsg-keypair root@ec2-72-44-33-55.z-2.compute-1.amazonaws.com

  The authenticity of host  'ec2-72-44-33-55.z-2.compute-1.amazonaws.com (216.182.225.42)' can't be  established.
  RSA key fingerprint is  9d:0a:a9:51:32:38:11:83:a8:a7:1c:9c:1c:e6:58:b0.
  Are you sure you want to continue connecting (yes/no)?  yes
  Warning: Permanently added  'ec2-72-44-33-55.z-2.compute-1.amazonaws.com' (RSA) to the list of known hosts.
  Last login: Wed Jun 21 08:02:08 2006
  root@my-instance # uname -v
  2.6.18-xenU
  root@my-instance #

The AKI and ARI that the the instance is running are also exposed in the instance meta-data. Notice the latest version is 2008-02-01 or greater.

$ curl http://169.254.169.254/
  1.0
  2007-01-19
  2007-03-01
  2007-08-29
  2008-02-01

The relevant new meta-data fields are kernel-id, ramdisk-id and ancestor-ami-ids:

$ curl http://169.254.169.254/2008-02-01/meta-data/
  ami-id
  ami-launch-index
  ami-manifest-path
  hostname
  instance-id
  instance-type
  local-hostname
  local-ipv4
  public-hostname
  public-ipv4
  public-keys/
  reservation-id
  security-groups
  ancestor-ami-ids
  kernel-id
  ramdisk-id
  
$ curl  http://169.254.169.254/2008-02-01/meta-data/kernel-id/
  aki-9b00e5f2
  

Bundling AMIs with a different AKI or ARI

In addition to specifying an AKI at launch time, you can create new AMIs that launch with a specified AKI by default. You can either rebundle an existing instance that was bundled with the desired AKI (as described above) or you can provide optional arguments to the ec2-bundle-vol command.

Note: You cannot change the default AKI of a registered AMI. You must rebundle and reregister it.

To bundle an AMI from a running instance that launched with an AKI, call the ec2-bundle-vol command as you normally would. The tool detects the AKI by inspecting the instance metadata (described above). The resulting AMI launches with the same AKI as the running instance.

To override the AKI that is currently bundled with an AMI, you can specify an AKI as a parameter to ec2-bundle-vol. To override the AKI, provide the –kernel parameter to ec2-bundle-vol.

Note: If you override the kernel in the bundling process, verify the AMI works with the requested AKI. It might be safer to relaunch your AMI with the desired kernel and bundle without an override.

The process of uploading the bundled image and registering the image is the same. After getting an AMI ID, instances launched using that AMI ID aree created with the kernel specified during the bundling process.



Related Documents
Type: Technical Documentation Docs: Amazon EC2 (API Version 2008-02-01)
Type: Release Notes Release: Amazon EC2 on 2008-03-27

Discussion

The 5 most recent discussion messages. View full discussion.

jigounov
Posts: 7
Registered: 6/8/08
Feature Guide: Amazon EC2 User Selectable Kernels
Posted: Jun 10, 2008 12:47 AM PDT
 
  Click to reply to this thread Reply

ec2-run-instances ami-2bb65342 -k gsg-keypair –-kernel aki-9b00e5f2
<pre>As I understand gsg-keypair should be similar to public key so I could ssh to this instance later.
Where do I get this gsg-keypair from? Is this one of those string identifiers provided with
my account, or is this file name of a public key which I should have generated
earlier or is this file name of public or private keys generated by amazon?


It keeps telling me this:
Client.InvalidKeyPair.NotFound: The key pair '/home/jigounov/.ssh/id_rsa.pub' does not exist
even though file is there and I have permissions to read it.
</pre>

jigounov
Posts: 7
Registered: 6/8/08
Re: Feature Guide: Amazon EC2 User Selectable Kernels
Posted: Jun 11, 2008 7:10 PM PDT   in response to: jigounov
 
  Click to reply to this thread Reply

Found correct instruction with extra steps for key generation here:
http://docs.amazonwebservices.com/AWSEC2/2007-08-29/GettingStartedGuide/?ref=get-started
click on "Running an instance" link.

Works like a charm.



Reviews
Create Review Write a Review
Be the first to review this.
Welcome, Guest Help
Login Login