Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
How did you create the AMI from the instance? AWS console? ec2-create-image command line? –  Eric Hammond Oct 26 '12 at 19:24
    
Command line: ec2-create-image <instance id> –  chris Oct 26 '12 at 19:27
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.