Steps to move EBS volume between EC2 instances

move-ebs-volume-banner

You can move EBS volume between EC2 instances  explicitly or by stopping/terminating the instance.

However, if the instance that the volume is attached to is running, you must unmount the volume (from the instance) before you detach it. Failure to do so results in the volume being stuck in the busy state while it is trying to detach, which could possibly damage the file system or the data it contains.

If an EBS volume is the root device of an instance, you must stop the instance before you can detach the volume.

Usecase scenario : You might want to use the volume on another instance or if you have any error regarding ssh or any other service files which is not allowing access to instance than you can detach the volume and rollback changes to files and attach back to recover instance.

Steps to move EBS volume between EC2 instances

Unmount the EBS volume (Optional only for non root volumes) :

You will have unmount the EBS volume if its in use.

First, use the following command to unmount the /dev/sdf device.

$ unmount -d /dev/sdf

Note : You cannot unmount EBS volume which is Root (the only volume attached to EC2 instance), hence in this case you have to stop instance. 

Step 1: Stop EC2 instance and detach EBS volume

detach-from-test1

Step 2:  Attach EBS volume to alternate EC2 instance

attach-to-test1

attach-info
Select EC2 instance to be attached to.
Enter the device name and Click attach

Once you have done this, now you can use the EBS volume on other EC2 instance.

Step 3 : Inorder to use first you’ll have to mount the volume and list the block device

$ mount /dev/sdf
$ lsblk

 

That’s it!

You’ll see the EBS volume listed and ready to be used.

Write you queries in below comment section, I’ll be happy to help.

Thanks for reading!

-Bhargav

 

 

Blogger & Assc Cloud Architect

Site Footer