Skip to main content

Command Palette

Search for a command to run...

Everything You Need to Know About AWS EBS (with Hands-on)

Updated
6 min read
Everything You Need to Know About AWS EBS (with Hands-on)
S

Hello, I’m Som, a DevOps Engineer passionate about streamlining operations through automation, continuous integration, and deployment. I am deeply passionate about exploring new technologies and continuously expanding my knowledge in the ever-evolving world of IT.

In this blog, we’ll dive deep into one of the most important storage services in AWS — Elastic Block Store (EBS).
By the end of this guide, you’ll not only understand what EBS is, but you’ll also create, attach, expand, take backups, and restore data between EC2 instances using snapshots.

Whether you’re a learner or an aspiring DevOps engineer, this hands-on guide will help you understand how EBS is used in the real world.

☁️ What is AWS EBS?

EBS stands for Elastic Block Store — it’s a persistent block storage service designed for use with Amazon EC2 instances.

Think of EBS as a virtual hard drive for your EC2 instances. It stores your data permanently (even after you stop or terminate your instance, if the volume is detached or backed up).

Each EBS volume is automatically replicated within its Availability Zone to protect you from hardware failures.

⚙️ Why EBS Matters

EBS volumes are essential in real-world projects because they:

  • Store databases, application files, or logs persistently

  • Allow you to scale storage dynamically

  • Let you back up data using snapshots

  • Enable disaster recovery by restoring snapshots to new instances

🧩 Step 1: Create an EC2 Instance

First, we’ll create an EC2 instance to attach our EBS volume to.

  1. Go to AWS Console → EC2 → Instances → Launch Instance

  2. Choose Ubuntu or any other image you’re comfortable.

  3. Select instance type (e.g., t2.micro)

  4. Configure key pair & security group

  5. Launch the instance

  1. Connect to the instance and check the default disk space 8G

  • This is the default EBS volume which is created along with the ec2 instance and will store your data.

🧩 Step 2: Create and Attach an EBS Volume

  1. Go to EC2 → Elastic Block Store → Volumes → Create Volume

  2. Choose:

    • Volume type: gp3 (SSD)

    • Size: 20 GB

    • Availability Zone: same as your EC2 instance (ap-south-1a)

  3. Click Create Volume

  4. Once created, give it a name, select it→ Actions → Attach Volume

    • Select your EC2 instance

    • Device name: /dev/sdk ( You can choose any one you like)

  5. Done! Your new EBS volume is now attached to your instance.

🧩Step 3: Mount and Use the EBS Volume

Now we’ll make the volume usable inside the EC2 instance. SSH into the instance and list the block devices lsblk

  1. Check disk partition - sudo fdisk -l . It shows the path of disk volume, use it to check the file system of the EBS volume

  1. To check the filesystem run - sudo file -s (path)

  • If the output is data then it means no file system is created for this EBS vloume and we need to create the file system for the EBS and later we have to mount it.

  • Command to make the file system - sudo mkfs -t xfs /dev/nvme1n1 ( use your disk path)

  • Let’s check the output of the file system again

  • Previously it was showing the data but now it’s changed to the filesystem. What’s next? We did pretty much everything what’s left is to mount this volume to the directory. Let’s create a directory and mount it to our EBS volume.

  • Directory is created let’s mount it now ( Command - sudo mount [path-of-ebs] [path-of-directory] )

  • There’s one more command to check that the volume is in use ( df -h )

  • As you can see from the 20G 425M is used, volume is in use now.

🧩Step 4: Increase the EBS Volume Size

Note: You can only increase the volume but you can not decrease it

In real-world scenarios, applications grow — so you’ll need to expand your storage.

  1. Go to EC2 → Volumes → Modify Volume

  2. Increase size (e.g., from 20 GB → 25 GB)

    • Click Modify → Yes

    • Wait for some minutes after you modify it. When it’s modified run - lsblk to recheck the volume size

    • Volume size is increased. Are we done ? No, here’s a twist your volume size does got increased but but but your file system size which you defined previously as 20G is still 20G. How to check it? Use df -h

  3. Well are we stuck ? No, here’s a simple and easy command to resize it ( - sudo xfs_growfs filesystem-name ).

  4. It’s done. Let’s more forward to the next part

🧩Step 5: Taking the snapshot of the data and attaching it to the another EC2 instance

Let’s first insert some data in the EBS and then we will take the snapshot of the EBS in short the data present in the EBS volume. Snapshot is the backup of the data. So if you want to backup some data in the snapshot make sure you have everything present cause snapshot will only backup the data which is present in the real time so we aware. After the snapshot is taken and the EBS volume is getting more data it won’t be saved.

  1. First I’ll go in the directory /ebsvolume where we mounted our EBS volume and will create some files there

  1. We created 2 demo files now let’s create another ec2 instance and then we will take the snapshot and attach it with the new ec2 instance

  2. Created Dev-2 ( new ec2 instance)

  1. Let’s move ahead and take the snapshot from the volume. Volumes → Select your volume → Actions → Create Snapshot

  1. Now you have a backup that you can use later to restore data or migrate to another instance.

  2. Snapshot is created but we have to create the volume from the snapshot in order to attach it with the EC2 instance so let's do it.

  3. Go to Snapshots → Select Snapshot → Actions → Create Volume ( Use the same or new Availability Zone and Keep size ≥ original )

  • Created the volume you can rename it whatever you want
  1. Now do the same attach process we did previously with the Dev-1 attach this vol to the newly created EC2 instance

  • It’s attached let’s verify from the console
  1. If you check the filesystem in the EBS it’s already there cuz we created it in the dev-1 vol the only thing left is to mount it

  1. Now the mount is complete. Let’s check if the data from the dev-1 vol is there or not.

The same data (demo1.txt, demo2.txt) appears here too!

You’ve successfully backed up and restored data using AWS EBS snapshots.

Note: If you create any new files in the dev-1 it won’t be reflected in the dev-2

Blog Summary

In this blog, I explored everything you need to know about AWS EBS (Elastic Block Store) — from understanding how it works to hands-on implementation. I covered creating and attaching EBS volumes to EC2 instances, resizing storage, taking snapshots for backups, and restoring them in another EC2 instance. Perfect for anyone looking to get real, practical AWS experience!

More from this blog

Som Pandey's blog

92 posts

Hello, I’m Som, a DevOps Engineer passionate about streamlining operations through automation, continuous integration, and deployment.

Everything You Need to Know About AWS EBS (with Hands-on)