Configuring EC2 storage (EBS) Hands On
Tags: aws, cloud, tutorial, beginners
Published: 2021-06-24 05:19:24

We will do a hands on EBS volumes so that we can understand how to attach an EBs volume to an EC2 instance.


* Start creating an [EC2 instance](https://dev.to/this-is-learning/start-an-instance-on-aws-ec2-hands-on-2hb3)

* In step 4 Add Storage we can see there are many options regarding storage.

  1. Size of storage - Here we define how much storage we want attaches to our EC2 instance like our EC2 instance may contain node modules, python packages etc according to our needs 

  1. Type - Here we define what type of a storage we want do we want a more durable or the one which is focused on IOPS etc. You can learn more about it from the [documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html)

  1. IOPS - How many input output operations we want per second

  1. Delete on termination - Check this checkbox if we want to delete EBS volume on termination 

  1. Encryption - If we generate a key we can encrypt our data using that AWS key. 

![EBS storage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2uulof3e7imc49y00e6n.png)

* Now we can create our instance with the selected storage

* You can check the details of the of our EBS storage in the storage tab once we select an EC2 instance

![EBS storage tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cv5dw5msb62ap1jea26d.png)

## Create a new EBS storage 

We can also create an independent storage which we can later join to our EC2 instance 

* To create a new EBS storage go to our EC2 dashboard and select volumes under elastic block store. You will see that there is our already created EBS volume. To create a new volume click on create volume

![Ebs storage 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gipeiy27n3zl7gf6gcaz.png)

* You will see the same options that we saw earlier while creating our EC2 instance.Remember to create the volume in the same availability zone as in the EC2 instance.

![Ebs storage 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z3de57r30i7xwdjtjqan.png)

* We get a status successful page and voila we created a new volume for our EC2 instance
![Ebs storage 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w6sdc7z62kn91bclpevn.png)

## Attach an EBS volume to an EC2 instance

* To attach an EBS volume to an EC2 instance right click on your EBS volume and click attach volume

![Attach volume 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ck9z1dshc4tn3iw0h6qn.png)

* You will see a dialog from where you can attach your EBS volume to an instance

![Attach volume 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pbmcmq3vmq2hwb8z1o8t.png)

* Right now we have attached an EBS volume to our EC2 instance but we will need to format it with a file system to use it with our EC2 instance like any other storage. Which is a bit complex and out of scope for this tutorial but you can check that out in the [documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html)
![Attach volume 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sftehmw77ysof0jj1p6d.png)

* If you terminate your instance then the one on which we selected delete on termination will be deleted

![terminate 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lrlby3ztjk6k8lfhc12c.png)
![Terminate 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0dedpbwcx0hsxhlpnsoa.png)
![terminate 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zlo911uu5lm7jmrd4189.png)


## Use snapshots to move EBS volumes

We can only work with our EBS volumes in one availability zone bout how to move them across availability zones. To do that we can use snapshots

* To create a snapshot go to the volumes in EC2 dashboard 
under Elastic Block Store

![Snapshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8we56xfy5epg6fwq5b0i.png)

* Select the volume and on the top click on actions. You will see an option for create snapshot
![Snaphot 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dlg3l4yjeradwu8eaeal.png)

* Click create snapshot after that you will see the screen below and put a description for our snapshot. Click on create snapshot. Your snapshot is created.
![snapshot2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtl0mbe2c1eobp5y9o9z.png)
![snapshot 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ni1a4nj2somfc42iiko4.png)


* It will take some time to create a snapshot but after sometime you can see the snapshot under snapshots under Elastic Block Store
![creaed snapshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4k4m8h70ofrfps3fcmw1.png)

* Once you are in these select the snapshot and from actions you can select copy.
![copy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7nygn9zh8e5qrl3gzc9c.png)

* Now you can see options to copy it across regions. If you want to copy it in any other region you can do it here.
![copy region](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yq2oo0pj181jw5o1fgyd.png)

* Now we can go across regions but still cannot copy across availability zones. To create a volume across Availability zone select snapshot -> click actions -> select create volume -> now you can create a volume with the data from the selected snapshot.
![copy az](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5u3iltf3lnnbz30mfdzf.png)

* Here we get the option to change Availability zone or change disk size. Same way you can create a new volume using  snapshots across regions.
![copy az 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tnf1shf58h03o9059jiy.png)

![copy az result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2bwpqudbqkhs1v0039up.png)

## Cleanup
Delete all the volumes and EC2 instances they may cost you money

Wow we learnt a lot of things today this may seem trivial once you are done with it but think of it in terms of physical servers how how will it take to move your servers disk space from one region into another. How long will it take to change capacity. Isn't it just wonderful how easy cloud made software operations. Next series amazon devices joined to physical drives EFS for a better throughput that network devices.