3

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?

Phillip B Oldham
  • 1,026
  • 5
  • 15
  • 24

2 Answers2

2

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.

gareth_bowles
  • 9,127
  • 9
  • 34
  • 42
1

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.