Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does an Amazon EC2 instance select its kernel?

I have an Amazon EC2 instance using the Amazon-supplied Fedora 8 64-bit AMI, which I would like to upgrade to Fedora 10.

I tried doing this by running "yum update" to upgrade the kernel and all packages. This seemed to work fine and I see that I now have the fc10 kernel installed, and all of my installed packages have also been updated to the Fedora 10 versions.

However, I also noticed that the fc8 kernel is still installed, and when I reboot my image it comes back running the fc8 kernel, not the fc10 kernel (I'm inferring this from the output of "uname -a").

Are there some additional steps I need to take to get my image to boot under the fc10 kernel, or is this even possible ? The Amazon documentation didn't turn up anything useful for me.

like image 935
gareth_bowles Avatar asked Jan 15 '09 22:01

gareth_bowles


2 Answers

You can create your own AMI but you need to use the Amazon-supplied kernels. The newest they provide is 2.6.21. I have a list of the fc (Fedora Core) kernels that I use for CentOS instances. I'm pretty sure they work fine with Ubuntu as well.

You'll want to bake these into your AMI when you register it using ec2-register. They can be changed at the time you start an instance but I like having the proper AKI (kernel) and ARI (ramdisk) to start with. Adding support for the ephemeral disks is helpful as well. You're paying for the extra storage with larger instances, you might as well use it. My magic incantation for ec2-register:

ec2-register --snapshot snap-12345678 -K pk-XXXXXXXXXXX.pem -C cert-XXXXXXXXXXX.pem \
--description "EBS CentOS 5.5 i386" --name "base-image-i386-4" --architecture i386 \
--root-device-name /dev/sda1 -b /dev/sdb=ephemeral0 -b /dev/sdc=ephemeral1 \
-b /dev/sdd=ephemeral2 -b /dev/sde=ephemeral3 --region us-east-1 \
--kernel aki-6eaa4907 --ramdisk ari-e7dc3c8e

You can change region, snapshot ID, description, name, arch, etc.

Also remember the kernels & ramdisks are region-specific. I can't remember where I got this list but I had trouble finding it. Hope it helps someone out.

2.6.21 kernels are available as:

US Region:

32-bit:

* aki-6eaa4907
* ari-e7dc3c8e
* ami-48aa4921

64-bit:

* aki-a3d737ca
* ari-4fdf3f26
* ami-f61dfd9f

EU Region:

32-bit:

* aki-02486376
* ari-aa6348de
* ami-0a48637e

64-bit:

* aki-f2634886
* ari-a06348d4
* ami-927a51e6

AP Region:

64-bit:

* aki-07f58a55
* ari-27f58a75
* ami-ddf58a8f

32 -bit

* aki-01f58a53
* ari-25f58a77
* ami-c3f58a91
like image 118
JKG Avatar answered Oct 04 '22 22:10

JKG


You cannot upload your own kernel image to EC2/Amazon. Only authorized users can upload kernel images. Even when you upload your own Linux OS image and boot from it in EC2, a predetermined kernel is loaded that is not the same as the one you initially uploaded. This is a policy decision made by Amazon. The most you can do is to change the default kernel version selecting from a list of predetermined and available amazon kernels that you want your instance to boot up with.

You can however build your own kernel module(s) or rebuild the ones for the kernel that gets loaded. Compiling your own module or recompiling the modules provided by the kernel being loaded gets a bit tricky as the kernel in amazon is a modified one with Xen hypervisor. You need to find out the specific kernel source code that gets loaded in your instance.

Cheers

Ernesto Benedito

like image 36
Ernesto Benedito Avatar answered Oct 04 '22 20:10

Ernesto Benedito