EC2上,我使用的rightscale的AMI为centos5的V1版本,该版本的kernel版本为2.6.16。
可以使用下面的方法升级到2.6.18.
因为,amazon允许在启动的时候选择kernel版本,amazon提供的最新内核的版本为2.6.18(其实,rightscale就是使用amazon提供的2.6.18的内核),所以,可以选择使用2.6.18的kernel启动以后再将INSTANCE重新打包成AMI。下面有官方文档。
注:使用了2.6.18kernel后,启动后,查看output中的输出,有下面的错误
解决的办法:
Untar the file and you will get two folders boot and lib. Copy the files under boot to /boot of your ami. and similarly mv the contents of lib/modules to /lib/modules of the instance. When launching your ami, mention the kernel id too -- the one of the link is aki-9b00e5f2 。
使用aki-9b00e5f2(32位)启动ami,然后,上传module到相应的目录,然后重新打包成AMI。
module下载地址在下面的官方文档中有说明。
http://developer.amazonwebservices.com/connect/entry!default.jspa?categoryID=112&externalID=1345&fromSearchPage=true
如果你想找某个版本的kernel,你可以在amazon的ami里搜索
Feature Guide: Amazon EC2 User Selectable Kernels
This guide introduces the User Selectable Kernels for Amazon EC2.
AWS Products Used:Amazon EC2Language(s):OtherDate 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
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.