EC2 Instances Storage : EBS Volumes

vipul pachauri
4 min readMay 11, 2022

--

Welcome to this section, where we will at look the different storage options for EC2 instances. So first, the most important ones are going to be EBS Volumes, so let’s define what they are.

What is EBS Volume

EBS : EBS Volume stands for Elastic Block Store. It’s a network drive that you can attach to your instances while they run, and we’ve been using them without even knowing. So this EBS Volumes allow us to persist data, even after the instance is terminated and so that’s the whole purpose, we can recreate an instance and mount to the same EBS Volume and we’ll get back our data. That is very helpful.

These EBS Volumes, at the CCP level, can only be mounted to one instance at a time, okay!

EBS Volume Specification

When you create an EBS Volume, it is bound to a specific availability zone.

So, How do you think of EBS Volumes?

Well, you can think of them as network USB sticks. So, it’s a USB stick that you can take from a computer and put it in another computer but you actually don’t physically put it in a computer. It’s attached through the network. The feature gives us 30 GBs of free EBS storage of type General Purpose or SSD or Magnetic per month.

So, EBS Volumes are network drivers, that is not a physical drive, okay!! So to communicate between the instance and the EBS Volume, it will be using the network and because the network is used, there may be a bit of latency from one computer to reach to another server.

Now, EBS Volumes, because they are a network drive they can be detached from an EC2 instance and attached to another one very quickly and that’s makes it super handy, when you want to do fail-overs.

EBS Volumes are locked to a specific availability zones, that means that, if it’s created in us-east-1a, it cannot be attached to us-east-1b, but if we do a snapshot, then we are able to move a volume across from different availability zones.

And finally, it’s a volume, so you have to provision capacity in advance. So you need to say how many GBs you want in advance and the IOPS, which is I/O operations per seconds, and you’re basically defining how you want your EBS Volume to perform. You’re going to get billed for that provision capacity and you can increase the capacity over time

EBS volume with AZ

Well, we have us-east-1a with one EC2 instance and we can attach, for example, one EBS Volume to the EC2 instance. If we create another EC2 instance, an EBS Volume can not be attached to two instances at a time at the Certified Cloud Practitioner level. And therefore, this other EC2 instance needs to have its own EBS Volume attached to it, but it is a very possible for us to have two EBS Volumes attached to one instance. Think of it as two network USB sticks into one machine that makes a lot of sense. Now EBS Volumes are linked to an availability zone.

So as we can see if you want it to have other EBS Volumes in another AZ then you would need to create this separately in the other availability zone. So just same way that’s your EC2 instances are bound to an AZ, so are the EBS Volumes. Finally, it is possible for us to create EBS Volumes and leave them unattached, they don’t need to be necessarily attached to an EC2 instance, they can be attached on demand and that makes it very, very powerful.

EBS — Delete on termination attribute

Finally, when we go ahead and create EBS Volumes through EC2 instances, there is this thing called a Deletes on Termination attribute ,when we create an EC2 instance there is the second to last column called Delete on Termination and by default, it is ticked for the Root Volume and not ticked for a new EBS Volume.

So this controls the EBS behavior, when an EC2 instance is being terminated. So by default, as we can see, the root EBS Volume is deleted alongside the instance being terminated. So it’s enabled and the default any other attached EBS Volume is not deleted because it’s disabled by default.

But obviously as we can see in this UI, we can control if you want to enable or disable delete on termination. And so use case right, would be for example,

if you want to preserve the root volume, when an instance is terminated, for example, to save some data, then you can disable delete on termination for the root volume, and you’ll be good to go.

So I hope you liked it. Thanks for reading. Happy learning !!

--

--

vipul pachauri
vipul pachauri

Written by vipul pachauri

Senior Software Backend Engineer

No responses yet