3

I have an EBS-backed instance with a 2nd mounted volume (I followed the steps in Eric's Article)

I then created an AMI from that instance, and ran an instance from that AMI.

That 2nd instance then created two volumes.

Is there a way to control how the volumes associated with with an AMI are created, or is the solution just to unmount the 2nd volume before creating the AMI?

2
  • How did you create the AMI from the instance? AWS console? ec2-create-image command line? Oct 26, 2012 at 19:24
  • Command line: ec2-create-image <instance id>
    – chris
    Oct 26, 2012 at 19:27

1 Answer 1

3

The ec2-create-image command line tool has a --block-device-mapping option to define the volumes associated with new instances.

http://docs.amazonwebservices.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-CreateImage.html

In your specific case, you may want to suppress the automatic creation and attaching of the database volume by specifying something like:

ec2-create-image --block-device-mapping /dev/sdh=none [...]

This will let you create and attach your own volumes to the new instances.

Alternatively, you could specify that an empty volume be created an attached when a new instance is started:

ec2-create-image --block-device-mapping /dev/sdh=:20:false [...]

When you run an instance, you could override the size of that volume using the --block-device-mapping option to ec2-run-instances.

It's also worth learning about the delete-on-termination flag for --block-device-mapping so that you understand how to control whether your second volume should automatically be deleted when the instance is terminated.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .