Managing AWS EBS Volumes on EC2 Instances

Managing AWS EBS Volumes on EC2 Instances

If I had to relearn Linux for observability…

I would master AWS EBS volume management early

because in the cloud, storage problems = production incidents.

✅ Expand observability storage without stopping the server

✅ Add separate volumes for logs, metrics, and data

✅ Protect workloads during scale-outs and backups

✅ Restore services faster when disk fills up


🛠️ What is an EBS Volume?

  • EBS (Elastic Block Store) = AWS's managed "hard disks."
  • Acts just like a normal Linux block device.
  • Can be attached to one EC2 instance at a time (for standard volumes).
  • Supports: Snapshots (backups), Volume resizin,g Different performance types (gp3, io2, st1, sc1)

✅ It’s your cloud "disk" that persists even if the instance reboots!


🔧 How to Manage EBS Volumes on EC2 (Step-by-Step)


1️⃣ Create an EBS Volume

✅ Go to AWS Console ➔ EC2 ➔ Elastic Block Store ➔ Volumes ➔ Create Volume

  • Choose size, type (gp3 recommended for general use)
  • Choose the same Availability Zone as your EC2 instance


2️⃣ Attach EBS Volume to EC2 Instance

✅ After creating the volume:

  • Select it ➔ "Attach Volume" ➔ Choose your EC2 instance

Example: It appears as /dev/xvdf, /dev/sdf, etc.


3️⃣ Connect to Your EC2 Instance

ssh -i mykey.pem ec2-user@<public-ip>        

✅ You must SSH into the instance to work with the volume.


4️⃣ Prepare the Volume

Check if the volume is detected:

lsblk        

You should see a new device, e.g., /dev/xvdf.

✅ If it's a brand new volume (blank), you must format it:

sudo mkfs.ext4 /dev/xvdf        

✅ If you attached an existing volume with data, skip formatting!


5️⃣ Mount the Volume

sudo mkdir /mnt/data
sudo mount /dev/xvdf /mnt/data        

✅ Now /mnt/data contains the volume’s filesystem.


6️⃣ Make Mount Permanent (Auto-Mount on Reboot)

Edit /etc/fstab:

Get UUID first:

sudo blkid /dev/xvdf        

Example fstab entry:

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/data ext4 defaults,nofail 0 2        

✅ Always use UUID instead of device name to avoid issues after reboot!


7️⃣ Expand an Existing EBS Volume

✅ If you run out of space:

  1. Expand the volume in AWS Console (Elastic Block Store ➔ Modify Volume).
  2. On EC2:

lsblk  # check updated size
sudo growpart /dev/xvdf 1
sudo resize2fs /dev/xvdf        

✅ Now the filesystem knows about the extra space!



Article content

Simple Analogy

Managing AWS EBS Volumes is like managing external hard drives for your laptop 🧳:

  • Create a drive (Volume) 📦
  • Plug it into your computer (Attach to EC2) 🔌
  • Format it (if needed) 🧹
  • Mount it and use (open drive folder) 📂
  • Resize drive if running low (expand volume) ➡️🆙

✅ In AWS, you plug, unplug, resize drives

without shutting down the machine!


🗺️ Where Are We in the Linux Journey?

Physical Disks → Logical Volumes → Cloud Storage (EBS) → Dynamic Observability Scaling        

✅ You now understand how storage works not just in Linux, but inside the cloud too.

To view or add a comment, sign in

More articles by Anamika Sanjay

Insights from the community

Others also viewed

Explore topics