云计算 频道

关于EC2上的ami的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

kernel2.6.18 Source

http://ec2-downloads.s3.amazonaws.com/xen-3.1.0-src-ec2-v1.0.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.

0
相关文章