DEV Community

Morodolu Oluwafikunayomi
Morodolu Oluwafikunayomi

Posted on

What is Amazon EBS? (And How to Create and Use It on AWS)

When working with Amazon EC2, one of the first things you’ll eventually realize is your instance doesn’t save data by default.
Surprising, right? You spin up an instance, run your code, maybe install some stuff — then you stop it and boom. It’s all gone.
That’s where Amazon Elastic Block Store (EBS) comes in. And if you're building anything remotely serious on AWS, you need to know how it works.
In this article, you’ll learn:

  • What EBS actually is
  • What it’s used for
  • How to create an EBS volume
  • How to attach and use it on your EC2 instance

Firstly: What is Amazon EBS?
Amazon Elastic Block Store (EBS) is a persistent block-level storage service designed for use with Amazon EC2. Think of it like a virtual hard drive in the cloud that retains your data even after your instance stops or terminates.
EBS volumes:

  • Act like physical disks attached to a machine
  • Can be resized, backed up, or restored at any time
  • Are highly available and reliable within a given availability zone
  • Support multiple performance tiers (e.g., SSD or HDD)

In short, if EC2 is your server, EBS is its hard drive.

Why Use EBS?

Here’s why EBS is essential for most AWS workflows:

Feature Why It Matters

  • Persistence Data is preserved even when EC2 stops or restarts
  • Scalability You can scale from 1 GB up to 64 TiB per volume
  • Snapshots Easy backups to S3, with point-in-time recovery
  • Encryption Secure your data at rest and in transit using AWS KMS
  • Performance Tiers Choose between gp3, io2, st1, and sc1 depending on your workload

Whether you’re running a database, storing logs, or hosting a production app, EBS gives you control and durability.

How to Create an EBS Volume (Step-by-Step)
Let’s walk through the process using the AWS Console.
Step 1: Go to EC2 → instance:
From the AWS Console, search for EC2, then click on "instance" under the “instances” section on the left sidebar, and click on launch instance, once in the page, fill in the name of the instance you wish to create


then select the virtual operating system you wish to use, for this tutorial we are using amazon linux.

then choose the instance type to t2.micro and create your key pair name, leave the remaining selected as is, and create the key pair, the key serves as your passkey to your instance created. but of this instance i already have a keypair name so as to reduce the amount of keypair i have on my system,

then click on launch instance, after which it should show a page as shown below


click on the string instance id

while your in the page for the of the instance created, scroll on the instance properties to the availability zone and take note of it, this will come in handy, as it not every time the availability zone will be the same, for this tutorial the availabilty is

us-east-1d

Step 2: Go to EC2 → Volumes
From the AWS Console, search for EC2, then click on "Volumes" under the “Elastic Block Store” section on the left sidebar.
then
Create a New Volume
Click “Create Volume” and set the following:
Size: e.g., 10 GiB
Volume Type: gp3 (General Purpose SSD)
Availability Zone: Must match your EC2 instance’s AZ(availability zone)
Encryption: Optional, but recommended for sensitive data
after your done, click on the create volume.

the arrow highlighted yellow shows the default storage block from the instance we created, it host the operating system files

The next step is,
Attaching the Volume to an EC2 Instance
Once the volume is created:

  • Go back to Volumes
  • Select your new volume
  • Click Actions → Attach Volume
  • Click Attach

Your EBS volume is now linked to the instance — but not yet usable.

In order to make your created EBS storage usable, go over to your favorite terminal, i will be using CMD for this tutorial

#change directory to downloads
cd downloads

#to connect to the instance
ssh -i "keypairname.pem" ec2-user@ip address of the instance

# View attached storage devices
lsblk

# Format the volume (use your correct device name if different)
sudo mkfs -t ext4 /dev/xvdbb

# Create a directory to mount it
sudo mkdir /mnt/data

# Mount the volume
sudo mount /dev/xvdbb /mnt/data
Enter fullscreen mode Exit fullscreen mode


now we make a file inside the storage To make it persist after a reboot


inorder to test if it is still persistent, you can stop the instance by going to the instance and right clicking on the running instance and clicking stop, after a min or two min start it back up and run the same set of code again but skipping the echo instance you should see the same file again.
Do note that

  • always Clean Up
  • To avoid unwanted charges:
  • Unmount the volume if you're no longer using it
  • Detach it from your EC2 instance
  • Delete the volume via the AWS Console if you’re done with it
  • AWS charges by the amount of provisioned GB per month, so it’s smart to manage unused volumes.

Amazon EBS is a foundational service that gives your EC2 instances reliable, scalable, and persistent storage. Once you understand how to create, attach, and manage EBS volumes, you unlock a key part of building robust infrastructure on AWS.

Whether you’re just experimenting or running production apps, EBS lets you:

  • Store data reliably
  • Back it up easily
  • Scale when needed
  • Mastering EBS is a small step that pays off big in the cloud.

Have questions, tips, or got stuck somewhere? Drop a comment below — let’s figure it out together. 👇

Top comments (0)