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

hd0

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/bzImage root=/dev/xvda1 rootfstype=ext4

hd00 multi-partition

If you partitioned the root device, you need to use the hd00 pv-grub aki. As before, pv-grub looks for /boot/grub/menu.lst on the first partition of the hard drive.

If the first partition is a dedicated boot partition and the second partition is the root partition, the configuration file will be /boot/boot/grub/menu.lst. This is because it is looking for /boot/grub/menu.lst in the 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 3
title EC2
root (hd0,0)
kernel /boot/bzImage root=/dev/xvda2 rootfstype=ext4

hd00 single-partition

However, if for example there is only one partition on the root device (thus making it the root partition), the configuration file will be /boot/grub/menu.lst.

/boot/grub/menu.lst
1
2
3
4
5
6
# Sample /boot/grub/menu.lst for hd00
default 0
timeout 3
title EC2
root (hd0,0)
kernel /boot/bzImage root=/dev/xvda1 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*

Using aws cli:

Console - user@hostname ~ $
1
2
3
4
5
6
7
8
9
10
11
12
13
aws --region=us-east-1 ec2 \
describe-images \
--owners "[\"amazon\"]" \
--filters "[
    {
        \"Name\": \"image-type\",
        \"Values\": [\"kernel\"]
    },
    {
        \"Name\": \"manifest-location\",
        \"Values\": [\"*pv-grub*\"]
    }
]"
Output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
{
    "Images": [
        {
            "VirtualizationType": "paravirtual",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-407d9529",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "i386",
            "ImageLocation": "ec2-public-images/pv-grub-hd0-V1.01-i386.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel"
        },
        {
            "VirtualizationType": "paravirtual",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-427d952b",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "x86_64",
            "ImageLocation": "ec2-public-images/pv-grub-hd0-V1.01-x86_64.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel"
        },
        {
            "VirtualizationType": "paravirtual",
            "Name": "pv-grub-hd00_1.04-x86_64.gz",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-499ccb20",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "x86_64",
            "ImageLocation": "amzn-ami-us-east-1/pv-grub-hd00_1.04-x86_64.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "137112412989",
            "Public": true,
            "ImageType": "kernel",
            "Description": "PV-GRUB release 1.04, 64-bit, configured for (hd0,0)/boot/grub/menu.lst"
        },
        {
            "VirtualizationType": "paravirtual",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-4c7d9525",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "i386",
            "ImageLocation": "ec2-public-images/pv-grub-hd00-V1.01-i386.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel"
        },
        {
            "VirtualizationType": "paravirtual",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-4e7d9527",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "x86_64",
            "ImageLocation": "ec2-public-images/pv-grub-hd00-V1.01-x86_64.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel"
        },
        {
            "VirtualizationType": "paravirtual",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-525ea73b",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "i386",
            "ImageLocation": "ec2-public-images/pv-grub-hd00_1.02-i386.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel"
        },
        {
            "VirtualizationType": "paravirtual",
            "Name": "pv-grub-hd00_1.04-i386.gz",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-659ccb0c",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "i386",
            "ImageLocation": "amzn-ami-us-east-1/pv-grub-hd00_1.04-i386.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "137112412989",
            "Public": true,
            "ImageType": "kernel",
            "Description": "PV-GRUB release 1.04, 32-bit, configured for (hd0,0)/boot/grub/menu.lst"
        },
        {
            "VirtualizationType": "paravirtual",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-805ea7e9",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "i386",
            "ImageLocation": "ec2-public-images/pv-grub-hd0_1.02-i386.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel"
        },
        {
            "VirtualizationType": "paravirtual",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-825ea7eb",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "x86_64",
            "ImageLocation": "ec2-public-images/pv-grub-hd0_1.02-x86_64.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel"
        },
        {
            "VirtualizationType": "paravirtual",
            "Name": "pv-grub-hd0_1.03-x86_64.gz",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-88aa75e1",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "x86_64",
            "ImageLocation": "ec2-public-images/pv-grub-hd0_1.03-x86_64.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel",
            "Description": "PV-GRUB release 1.03, 64-bit, configured for (hd0)/boot/grub/menu.lst"
        },
        {
            "VirtualizationType": "paravirtual",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-8e5ea7e7",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "x86_64",
            "ImageLocation": "ec2-public-images/pv-grub-hd00_1.02-x86_64.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel"
        },
        {
            "VirtualizationType": "paravirtual",
            "Name": "pv-grub-hd0_1.04-i386.gz",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-8f9dcae6",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "i386",
            "ImageLocation": "amzn-ami-us-east-1/pv-grub-hd0_1.04-i386.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "137112412989",
            "Public": true,
            "ImageType": "kernel",
            "Description": "PV-GRUB release 1.04, 32-bit, configured for (hd0)/boot/grub/menu.lst"
        },
        {
            "VirtualizationType": "paravirtual",
            "Name": "pv-grub-hd0_1.04-x86_64.gz",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-919dcaf8",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "x86_64",
            "ImageLocation": "amzn-ami-us-east-1/pv-grub-hd0_1.04-x86_64.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "137112412989",
            "Public": true,
            "ImageType": "kernel",
            "Description": "PV-GRUB release 1.04, 64-bit, configured for (hd0)/boot/grub/menu.lst"
        },
        {
            "VirtualizationType": "paravirtual",
            "Name": "pv-grub-hd00_1.03-i386.gz",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-b2aa75db",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "i386",
            "ImageLocation": "ec2-public-images/pv-grub-hd00_1.03-i386.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel",
            "Description": "PV-GRUB release 1.03, 32-bit, configured for (hd0,0)/boot/grub/menu.lst"
        },
        {
            "VirtualizationType": "paravirtual",
            "Name": "pv-grub-hd00_1.03-x86_64.gz",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-b4aa75dd",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "x86_64",
            "ImageLocation": "ec2-public-images/pv-grub-hd00_1.03-x86_64.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel",
            "Description": "PV-GRUB release 1.03, 64-bit, configured for (hd0,0)/boot/grub/menu.lst"
        },
        {
            "VirtualizationType": "paravirtual",
            "Name": "pv-grub-hd0_1.03-i386.gz",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "ImageId": "aki-b6aa75df",
            "State": "available",
            "BlockDeviceMappings": [],
            "Architecture": "i386",
            "ImageLocation": "ec2-public-images/pv-grub-hd0_1.03-i386.gz.manifest.xml",
            "RootDeviceType": "instance-store",
            "OwnerId": "206029621532",
            "Public": true,
            "ImageType": "kernel",
            "Description": "PV-GRUB release 1.03, 32-bit, configured for (hd0)/boot/grub/menu.lst"
        }
    ]
}

Using ec2-api-tools:

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