If I detatch an EBS volume from an EC2 instance and then attach it to another newly created EC2 instance, would that be okay? If it would work then would I need to install any libraries like PHP, apache, mysql etc again or they'd be installed automatically as they're already installed in the volume that I need to attach with it. Please let me know if my question makes sense. Thanks!
2 Answers
You need to be more specific. Can an EBS volume be detached from one EC2 instance and attached to another EC2 instance? Yes, as long as both instances are part of the same Availability Zone. EBS volumes can be thought of the same way as a portable Hard Drive. Now the caveat to this part of your question is, is this EBS volume the root volume, or was it added as an additional storage volume to an EC2 instance?
The part about installed software and libraries is meaningless as it provides no context. For example if you install PHP on an EC2 instance, and your personal running code is in a folder located on this EBS volume, then as long as you have PHP installed on the new EC2 instance, and you attach this volume to that EC2 instance, you can run that code the same as you did on the previous EC2 instance.

- 387
- 2
- 3
I'll work on the premise here that you are talking about the root EBS volume.
ie
You have launched an instance, and you now want to detach the EBS root volume, and attach that to another instance.
Yes, you can do this.
Stop the instance (1). Detach the root volume. Launch another instance (2), for which another root volume will be created. Stop that instance too, and detach the newly created volume. Attach the root volume from instance 1 to instance 2 as /dev/sda1 Start instance 2.
No need to re-install anything.
You can also accomplish the same effect by making an AMI from instance 1 and relaunching it as instance 2.

- 3,449
- 1
- 27
- 42