How to attach a volume to an instance of different availability zone?
Published: 2022-01-21 12:34:01

So, when we want to attach a volume of different availability zone to an instance then the concept of **SNAPSHOT** comes into the picture.
Suppose you have an instance, in **ap-south-1a** availability zone.!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdw918bje4xrnedu8dtv.jpg)
 
Now, suppose you have a volume of 15GB in different availability zone let it be in **ap-south-1b**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wj33qc452d1l24ps90ix.jpg) 

Then go the volume(which you want to attach) -> go to actions -> create snapshot -> add a description -> add tag (value = description name)-> create snapshot.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1tsnxmuckpv32hny6397.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/58mjpeijupgd7g064gvy.jpg)

Now, go to Snapshots you will find that a snapshot of your volume is being created.

Now, we need to create volume from the snapshot.
So, go to actions -> click on create volume from snapshot -> give size according to your wish -> change the availability zone according to the instance with which you want to attach the volume -> Give tag -> Create volume.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/na98i0kdpngmettkx2sb.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bo4xr3zytwi9av7afhmi.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i9b2opc8j6o71akiihsf.jpg)

Now, go to volumes you will find a new volume is created.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fsiryzuz9jgrw0ie2tb.jpg)

Now, you can add the new volume to your instance by following the below steps.
Step 1: Go to Xshell then type **sudo su** then type **lsblk**

We will fing a 8G volume is mounted into the root (/).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90ym9hlynjia6gvqjaj0.jpg)

Step 2: Then we need to add the volume to our instance so, go to 
your AWS console and then go to the volume section. Click on the volume you want to attach to your instance then go to actions -> click on attach volume, then follow the below steps. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/npa7q294l17758hljjs5.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bqiz5gspf5z78bgz1b6o.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jaiq99tez43prhmobe97.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tyhw5gmci950wulutx4q.jpg)

Step 3: Then go to Xshell, type **lsblk**, it will show that the 
extra volume is attached to the instance.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/788e4hjtggrz4jbfp78h.jpg)

Now, type **df -h**, we will find that the new volume is not showing on the instance details which means the new volume is attached but not mounted into the instance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvc711mco40zuemm4xx6.jpg)

So, to mount the volume here are the following steps:
Step1 : Type mkdir /india (making a directory)
Step2 : Type cd /india (changing directory)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rwrz4286qbrlyiju8jhh.jpg)

Then type **mount /dev/xvdf  /india/**. Now, our EBS volume is mounted on our AWS instance.
We can also check it by typing **df -h**, then we will see the 15G storage used in the our directory India. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9crggzbgyoezxz8ttf3g.jpg)

This is the whole process by which you can connect the volume and instance of different availability zones.