Resources



Articles and Tutorials

Updating an AMI's Kernel and Ramdisk

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

In order to upgrade your AMI to the latest kernel you will have to launch your existing AMI and rebundle it explicitly overriding the default bundling tools behavior - which is to use the instance meta-data service to determine your current kernel and ramdisk combination OR overriding the launch time kernel and ramdisk parameters.

AWS Products Used: Amazon EC2
Language(s): Other
Date Published: 2009-09-29

By way of example let's use the previous Fedora 8 release (v1.09).

An ec2-describe-images call would look as follows:

IMAGE    ami-520d2526
   ec2-public-images-eu/fedora-8-i386-base-v1.07.manifest.xml      amazon
   available        public          i386machine  aki-7e0d250a    ari-7d0d2509

Note the versions of the kernel 'aki-7e0d250a' and the ramdisk 'ari-7d0d2509'.

aki-7e0d250a    ec2-public-images-eu/ec2-vmlinuz-2.6.21.7-2.fc8xen.i386.manifest.xml
ari-7d0d2509    ec2-public-images-eu/ec2-initrd-2.6.21.7-2.fc8xen.i386.manifest.xml

But we want the updated kernel and ramdisk:

aki-02486376   ec2-public-images-eu/vmlinuz-2.6.21-2.fc8xen-ec2-v1.0.i386.aki.manifest.xml
ari-aa6348de   ec2-public-images-eu/initrd-2.6.21.7-2.fc8xen-ec2-v1.0.i386.ari.manifest.xml

What we'll do is launch the instance using the standard tools, but override it's default kernel and ramdisk parameters.

ec2run --key my-keypair --instance-type m1.small --kernel  aki-02486376
   --ramdisk ari-aa6348de ami-520d2526

So we're launching our old AMI but overriding the default kernel and ramdisk parameters with our new kernels.

Once the instance is up and running, we can perform our normal bundling operation as outlined in the documentation.

Now if you have an existing instance that we want to bundle, but it’s running on an older/different kernel we can do that by using the following flags for bundlevol:

bundlevol --kernel aki-02486376 --ramdisk  ari-aa6348de  --exclude
   /root/.ssh    ...[rest of parameters as above]

TIP: Don’t forget to clean up before bundling, you want to remove things like host keys, and logs. Here is a destructive example. DO NOT use it on live instances that you want to continue using.

# Remove logs
   find /var/log -type f -exec rm "{}" \;

# Remove history files
   rm -f /root/.viminfo /root/.lesshst /root/.bash_history

# Remove host ssh keys
   rm –rf /etc/ssh/ssh_host_*key*

# Set firstrun flag on Amazon images
   touch /root/firstrun

Discussion
Click to start a discussion on this document Create a New Discussion
No discussion has been created for this document.

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