switch ebs volume between instance

Here is the situation

In instance A , have EBS volume where my mysql db data located was created based on this http://qugstart.com/blog/amazon-web-services/how-to-set-up-db-server-on-amazon-ec2-with-data-stored-on-ebs-drive-formatted-with-xfs/

I want to move db into separate instance B so I have created instance and installed Mysql already.

Both instances and volume were in same region.

My question here was if I detach ebs volume from instance A and attach to instance B will work automatically or do I have to make any precaution steps?


If you are following the instructions from the link/blog. You don't have to shutdown the instance to detach the EBS volume. You only need to shutdown your EC2 instance if your EC2 volume is the root volume. i.e /dev/sda1 /dev/sda /dev/xvda

Having said that, you do need to shutdown your mysql service on instance A before detaching the volume:

service mysqld stop

Then you can bring up another instance B and then attach the EBS volume where your data is and then mount it. (Assuming you are attaching to /dev/sdh or /dev/xvdh)

echo "/dev/sdh /vol xfs noatime 0 0" | sudo tee -a /etc/fstab
sudo mkdir -m 000 /vol
sudo mount /vol

You can move EBS volumes, but before you detach it from the original server, you should stop the server.

When you attach the volume to the new server, look into EC2 console to see where it is attached to (i.e. /dev/xvdb). Then all you need is mount it somewhere. Your Mysql server's data directory should point to that mount location:


I have been able to easily detach ebs volumes from on instance and reattach to another running instance with no problems at all.

I would certainly make sure you first terminate any programs that may have open files or are using that volume before detaching.

Not very familiar with MySQL, but I assume when you attach the new volume you will need to let MySQL know about the database and where it is. In SQL Server you would do this by 'Attaching' it to a running sql server instance - mySQL probably has a similar process.

Need Your Help

Convert JSON string in html into JSON object

javascript jquery html json ajax

I've retrieved some data in JSON format from MarkitOnDemand API, the JSON content I want is inside the body tag of the html string like this:

Monitoring Bone cp Connection pool

java hibernate connection connection-pooling bonecp

We are trying to move to bonecp connection pool from c3p0. we use hibernate as the ORM tool.