Dowd and Associates

HowTo: Amazon EC2 Kernel Images - PV Grub

You can build your own kernel on Amazon EC2, so long as you pick the appropriate PV Grub kernel image.

Types of pv-grub kernel

There are two types of pv-grub kernel image:

  • hd0 – for boot disk images that are unpartitioned (as most on the cloud are)
  • hd00 – for boot disk images that are partitioned (as most physical servers are)

Configuration file

pv-grub looks for /boot/grub/menu.lst on the first partition of the hard drive. If you have just one partition for the whole root device, you’ll use the hd0 pv-grub kernel aki, and the configuration file will be located at /boot/grub/menu.lst.

/boot/grub/menu.lst
1
2
3
4
5
6
# Sample /boot/grub/menu.lst for hd0
default 0
timeout 3
title EC2
root (hd0)
kernel /boot/kernel-3.2.1-gentoo-r2 root=/dev/xvda1 rootfstype=ext4

If you partitioned the root device, you need to use the hd00 pv-grub aki, the boot partition needs to be the first one on the device, and the configuration file will be /boot/boot/grub/menu.lst. This is because it is looking for /boot/grub/menu.lst in the first partition, which is /boot.

/boot/boot/grub/menu.lst
1
2
3
4
5
6
# Sample /boot/boot/grub/menu.lst for hd00
default 0
timeout 30
title EC2
root (hd0,0)
kernel /boot/kernel-3.2.1-gentoo-r2 root=/dev/xvda2 rootfstype=ext4

Supported File Systems

The following file systems are supported for the partition with /boot:

  • ext2
  • ext3
  • ext4
  • xfs
  • reiserfs
  • btrfs

How to find pv-grub kernel

Note: change region as appropriate

Example Request
1
2
3
4
5
6
7
8
https://ec2.us-east-1.amazonaws.com/
?Action=DescribeImages
&Owner.1=amazon
&Filter.1.Name=image-type
&Filter.1.Value.1=kernel
&Filter.2.Name=manifest-location
&Filter.2.Value.1=*pv-grub*
&*AUTHPARAMS*
Console - user@hostname ~ $
1
2
3
4
5
ec2-describe-images \
--owner amazon \
--filter image-type=kernel \
--filter manifest-location=*pv-grub* \
--region us-east-1
Output
1
2
3
4
5
6
7
8
IMAGE   aki-407d9529    ec2-public-images/pv-grub-hd0-V1.01-i386.gz.manifest.xml        amazon  available       public          i386    kernel                          instance-store  paravirtual     xen
IMAGE   aki-427d952b    ec2-public-images/pv-grub-hd0-V1.01-x86_64.gz.manifest.xml      amazon  available       public          x86_64  kernel                          instance-store  paravirtual     xen
IMAGE   aki-4c7d9525    ec2-public-images/pv-grub-hd00-V1.01-i386.gz.manifest.xml       amazon  available       public          i386    kernel                          instance-store  paravirtual     xen
IMAGE   aki-4e7d9527    ec2-public-images/pv-grub-hd00-V1.01-x86_64.gz.manifest.xml     amazon  available       public          x86_64  kernel                          instance-store  paravirtual     xen
IMAGE   aki-525ea73b    ec2-public-images/pv-grub-hd00_1.02-i386.gz.manifest.xml        amazon  available       public          i386    kernel                          instance-store  paravirtual     xen
IMAGE   aki-8e5ea7e7    ec2-public-images/pv-grub-hd00_1.02-x86_64.gz.manifest.xml      amazon  available       public          x86_64  kernel                          instance-store  paravirtual     xen
IMAGE   aki-805ea7e9    ec2-public-images/pv-grub-hd0_1.02-i386.gz.manifest.xml         amazon  available       public          i386    kernel                          instance-store  paravirtual     xen
IMAGE   aki-825ea7eb    ec2-public-images/pv-grub-hd0_1.02-x86_64.gz.manifest.xml       amazon  available       public          x86_64  kernel                          instance-store  paravirtual     xen

For more info

Comments