DEV Community

Cover image for How To Move an EBS volume to another region?
Gurlal Sidhu
Gurlal Sidhu

Posted on

How To Move an EBS volume to another region?

Moving volumes across two regions is not permitted, however, creating a snapshot of a volume and then moving to another region is allowed. Let's see how it is done:

  1. Launch two instances in different regions( us-east-1 and us-west-1)
  2. Create a volume in the first region (us-east-1)

    1. Go to EC2, under Elastic Block Store (left pane), and click on Volumes
    2. Create volume. The size of this volume would be 10 GB
    3. Once it is successfully created, you will see its state set to available




  3. Now right on newly created volume and select ‘attach volume’

    1. Select your instance, leave the device as it is - /dev/sdf and attach. It will take a couple of minutes to attach the volume. pic4
    2. Now Connect to your EC2 Instance - either via SSH or connect directly from the portal. I will be connecting from the portal (it will open in another tab).
    3. First thing first, switch to root user - sudo su
    4. check if the attached volume is listed - lsblk
    5. New volumes don’t file system configure, set up a file system for this volume - mkfs -t xfs /dev/xvdf
    6. Create a mount point for your volume -mkdir gsdata and mount the volume - mount /dev/xvdf /gsdata
    7. Going to check if I can see all my buckets - aws s3 ls
    8. Copy files from Testing Vol folder in inpuutbuckgs bucket to /gsdata - aws s3 cp S3://inputbuckgs/TestingVol /gsdata --recursive
    9. Check moved files - ls -l /gsdata
    10. Now you could create directories upload files to this volume. I’ll create a test folder and move some files from s3 bucket.
    11. Before you copy files from the s3 bucket, you will need to configure your AWS profile. I have it already configured. pic5 pic6 pic7 pic8 pic9 pic10
    12. Now go back to the EC2 portal, and create a snapshot of the volume
    13. Right-click on the volume and select ‘create a snapshot’, Type in the description on the prompted screen, and create Snapshot
    14. Go to Snapshots under Elastic Block Store, right-click on this new snapshot, and select copy
    15. Select the region where you want to copy, add a description, and copy pic11 pic12 pic13 pic14
  4. Go to another region, check your snapshot that you just copied, it could take depending on the size of your snapshot

    1. Right-click on the snapshot and create Volume
    2. Select the size, type, and region on the prompted screen. Increasing size is ok, but if you try to reduce the size, you may experience data lose pic15 pic16 pic17
  5. EBS volume has been moved to another region. However, I am going to attach an instance in this region to show you that there was no data lost since the last snapshot

  6. Attach the volume like we did it above for an instance in us-east-1 region and connect to EC2 Instance

    1. Please don’t try to format the file system again, it will delete your data. Just mount the volume here. As you can see here, all the files that were uploaded in the us-east-1 region were available here. pic18 pic19 pic20 pic21

Now detach your volumes in both regions, delete volumes and snapshot, and terminate your instance to avoid any charges from AWS

Use case Scenarios of what we did above:

  • Perform a backup of your volume in another region.
  • Restore volume in another region from snapshot
  • Please Note: you could also create a Snapshot Lifecycle Policy that will create snapshots of your volume hourly, every two or four hours, or daily and retain those snapshots up to desired days.

Discussion (0)