I'm setting up a database server on EC2, and I need to ensure that an EBS volume is automatically attached and is available before the database service starts up.

I'm using SMF so I can test whether a particular filesystem is available before starting the db service, so there's no problem from that perspective, however I'm not quite sure how to tell the server to auto-attach the EBS volume during/after boot.

What would be the best strategy for this?

link|improve this question

33% accept rate
feedback

2 Answers

You just need a couple of short scripts -one to attach the EBS volume at boot time and the other to detach it on shutdown to make sure the shutdown is clean. See this AWS forum post.

link|improve this answer
feedback

You can use the -b flag of the ec2-run-instances or ec2-register commands to automatically create a volume from a snapshot and attach it at a specific block device location or create an empty volume. Ex:

ec2-run-instances [OPTIONS] AMI [AMI-OPTIONS] -b /dev/sda2=snap-1234abcd:50

where snap-1234abcd is the snapshot id, 50 is the size of the volume to be created. Either one is sufficient.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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