TristanMatthews
TristanMatthews

Reputation: 2571

Launch an aws instance from snapshot, can't find kernel ids

SHORT VERSION:

For AWS how do you find the kernel id from a given ami id, or from an instance launched with that ami.

LONG VERSION:

I have an aws instance where all drives are ebs backed. I'm trying to launch an exact copy of it from snapshots of the drives.

The first step in this process is to create a new ami from the root volume snapshot. When I have done this previously I've just googled the ami id and found somewhere that had the Kernel ID posted for the standard ubuntu ami I had selected from the aws console, but that doesn't seem to be work this time.

A lot of searching, reading the documentation, and aws forums makes it sound like the kernel file should be populated in the instance description, but for me (and a lot of other people in the forums) its blank. I tried launching a new (from the console) instance [Amazon Linux AMI 2014.09 (HVM) - ami-08842d60] the kernel field is blank for that one also.

If I create a brand new machine, snapshot it, and then leave the kernel as default the ami works just fine, but default doesn't work for any of the older ami's I have tried.

Any one have any idea what the process for finding kernek ID for an ami is these days?

Upvotes: 3

Views: 3564

Answers (2)

TristanMatthews
TristanMatthews

Reputation: 2571

SHORT VERSION:

It seems that you don't need a kernel id at all if your ami is an hvm, so long as your set your options right.

LONG VERSION:

If you create your ami using a boto call like:

    ami_id = conn.register_image(
        name='some_name',
        description='some_description',
        architecture='x86_64',
        root_device_name='/dev/sda1',
        snapshot_id=snapshot_id,
        delete_root_volume_on_termination=True)

It seems to work if the instance's original ami is the most recent hvm ami listed in the aws console. But stopped working once aws updated its default ami's. I assumed its because something on the backend picks up the right kernel id or something. Either way this working is VERY CONFUSING!

However if you set the virtualization_type to hvm it seems consistently works without a kernel id.

    ami_id = conn.register_image(
        name='some_name',
        description='some_description',
        architecture='x86_64',
        virtualization_type='hvm',
        root_device_name='/dev/sda1',
        snapshot_id=snapshot_id,
        delete_root_volume_on_termination=True)

On the other hand if your instance is paravirtual it seems that so long as you specify the kernel you don't need to specify the virtualization_type in the boto call.

Upvotes: 2

markA
markA

Reputation: 1609

Taken from AWS Documentation you can find the kernel Id with the following command on a running instance:

$ ec2-describe-instance-attribute instance_id --kernel --region region

Then you can get the version information from:

$ ec2-describe-images [kernelID you got from previous command] --region region

edit: Just noticed this is an HVM; Not sure why you would want to make an image from a snapshot. If you create an image directly from the ec2 it will also create snapshots for you and then you can go to AMIs and make a new ec2 from the image you created and it will not ask for a kernel ID.

If the instance is gone and you have nothing but snapshots I could understand what you are trying to do and, instead of trying to make an AMI from your snapshot, just make a volume out of it instead. Then launch a similar HVM based instance, let it boot, then stop it. Swap the root volumes out and start it back up.

Upvotes: 1

Related Questions