Cross Region Migration of AWS EBS Volumes

Asim SkAsim Sk
5 min read

Project Description

  • This project involves migrating AWS Elastic Block Store (EBS) volumes from one region to another. The goal is to seamlessly transfer data and configurations, ensuring minimal downtime and maintaining data integrity. The process includes planning, snapshot creation, volume replication, and final verification to successfully relocate EBS volumes across AWS regions.

Architecture

Comming Soon

Elastic Block Store (EBS)

EBS is a scalable and high-performance block storage service that provides persistent storage volumes for EC2 instances. It allows users to create and attach storage volumes to EC2 instances, offering reliable and low-latency storage for applications and data in the AWS cloud.

Step 1: Launch an EC2 Instance in the N. Virginia Region

  • Log in to your AWS Management Console.

  • Navigate to the EC2 Dashboard and click “Launch Instance.”

  • Choose an Amazon Machine Image (AMI), I have selected Amazon Linux and configure the instance.

  • Launch the instance and confirm it’s running.

  • Here you can see our instance is running on “us-east-1b” availability zone.

Alt text

Step 2: Create an EBS Volume in the N. Virginia Region

  • Click on Create volume

Alt text

  • Here in the Size you can give according your requirements, I have given 1GiB

  • And in the Availability Zone make sure to select those availability zone where we have launched our instance.

  • Here you can give the Tags and click on Create volume.

    Alt text

  • Now select your instance and click on connect you can use other tools like GitBash, putty for login.

  • login as root user by

sudo su - root
fdisk -l
  • The command is used to list the partitions and their details on a Linux system.

  • here you can see only one disk is attached.

    Alt text

  • Now let’s attach the EBS volume, select the volume that we have created, click on action and click on Attach volume.

Alt text

  • Here select the instance that we have launched and click on Attach volume.

  • Connect the instance and see new disk is attached.

Alt text

Step 3: Store Data in the EBS Volume

  • for storing the data in the ebs volume we have to create a partition.

  • To create a partition we have to go inside the hard disk with command.

fdisk /dev/xvdf
  • Type n for new partition

  • type p for primary partition

  • partition number 1

  • First sector enter

  • command to specify the Size +100M

  • Type w this command will save the partition

Alt text

The lsblk command in Linux is used to list information about block devices, Here you can see one partitons is created.

Alt text

Now we have to format the partition for this mkfs.ext4 command in Linux is used to create an ext4 file system.

mkfs.ext4 /dev/xvdf1

Alt text

  • now create a folder named myfold by mkdir /Asim command.

  • now we have to mount this folder to the created partition by command.

mount /dev/xvdf1 /Asim
  • now we see the the list of mount folder by df -h command, here you can see our folder is mounted.

Alt text

  • now go inside this folder by cd /Asim command and create a file and store the data.

Step 4: Create a Snapshot of the EBS Volume

  • for creating a snapshot select the ebs volume and click on action and click Create snapshot.

  • Give the tags and click on create snapshot.

Step 5: Copy Snapshot to the Mumbai Region

  • Now copy this snapshot in which region you want, I am copying to the Mumbai Region, for this select snapshot and click on action and click on Copy snapshot.

Alt text

  • Select the Destination Region in my case it’s ap-south-1 and click on copy snapshot .

    Alt text

Step 6: Create an EC2 Instance in the Mumbai Region

  • Navigate to the EC2 Dashboard in the Mumbai region.

  • Click “Launch Instance.”

  • Choose an AMI and configure the instance in Mumbai.

Alt text

Step 7: Create EBS volume from snapshot and attach to the instance.

  • In the Ohio region, go to ec3 dashboard, where click on Snapshot here you can see the one snapshot is copied from N.Virginia region.

  • Now select this snapshot and click on actions and click on Create volume from snapshot.

    Alt text

  • Here you can define the size of volume how many size you want according you can give, I have just given 1GiB.

  • And select Availability Zone where our instance is running in the Mumbai region in my case it’s running in ap-south-1b AZ and click on create volume.

Alt text

  • Now login to the console switch to root user and check the list of disk here you can see only one disk is attached.

Alt text

  • Now attach the volume to the instance, select the volume and click on actions and click on Attach volume.

Alt text

  • Here select the instance which we have launched and click on attach volume.

Alt text

  • now check the list of disk by command, here you can see one more disk is come up which size is 1GiB.
fdisk -l
  • Now we have to format this partition by command.
mkfs.ext4 /dev/xvdf1
  • Now create a folder by command here myfold is just a name of folder you can give anything.
mkdir /Asim
  • Now mount this folder to the new disk by command.
mount /dev/xvdf1 /Asim

Step 8: Verify Data Integrity in Mumbai

  • Now go inside this folder by cd /Asim command and list the file by ls command here you can see the file which we have create in N.Virginia region.

  • Now see the data which we have stored by cat aws.txt command, here you can see the exact same data.

Alt text

0
Subscribe to my newsletter

Read articles from Asim Sk directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Asim Sk
Asim Sk

Aspiring Software Developer 🚀 with a knack for JavaScript, React js, and Express js. Currently delving into web3 (Solidity, Ethereum, Hardhat, ethers.js). Excited about DevOps with Docker, Terraform, Jenkins, and Kubernetes. Ready to code, deploy, and innovate! 💻✨