Introduction:
In my recent project, I explored and implemented Amazon Elastic Block Store (EBS) — AWS’s durable block-level storage solution — by attaching, formatting, and persisting data on a running EC2 instance. This hands-on experience simulates how persistent storage is managed in real-world cloud applications.
This article documents the detailed steps I followed, practical scenarios where EBS shines, and how you can replicate it yourself — whether you're testing, running production workloads, or learning AWS infrastructure.
What is EBS?
EBS (Elastic Block Store) is like a cloud-based hard drive for EC2 instances. It allows you to store data persistently — even after rebooting or stopping your instance — unlike the ephemeral storage in Instance Store.
Imagine plugging a USB drive into your laptop, saving a file, and being able to unplug and move it to another device. That’s how EBS works in the cloud world.
Why Does EBS Matter?
Durability: EBS volumes persist data between instance stops, starts, and reboots.
Flexibility: Volumes can be attached/detached from running EC2 instances.
Security: Optional encryption ensures secure data at rest.
Backup: Snapshots let you back up volumes to S3 for recovery.
Types of EBS Volumes and Where They're Used
Type Description Real-World Use Case
gp2/gp3 General Purpose SSDs Web servers, app servers, dev/test environments
io1/io2 High-performance SSDs for IOPS-intensive apps Relational databases, NoSQL, high-transaction workloads
st1 Throughput-optimized HDDs Data warehouses, big data analytics
sc1 Cold HDDs (low cost, infrequent access) Backups, log archiving, rarely accessed data
Practical Implementation
Objective:
Attach a secondary EBS volume to a running EC2 instance, format it, mount it, write to it, and confirm data persistence after reboot.
Step-by-Step Guide
1. Launch an EC2 Instance
AMI: Amazon Linux 2023
Type: t2.micro (Free Tier)
Set SSH key and allow port 22 in the security group
2. Create an EBS Volume
Navigate to EC2 Dashboard > Elastic Block Store > Volumes
Click Create Volume
Type: gp2 or gp3
Size: 5 GiB
Availability Zone: Same as your EC2 (e.g., us-east-1a)
3. Attach EBS Volume to EC2
Select the new volume
Click Actions > Attach Volume
Choose your instance
Leave the device name as default (e.g., /dev/xvdf)
4. Connect via SSH and Format the Volume
bash
ssh -i my-best-Key.pem ec2-user@
# Check disk visibility
lsblk
Format the disk
sudo mkfs -t ext4 /dev/xvdf
Create mount point
sudo mkdir /data
Mount it
sudo mount /dev/xvdf /data
Write a test file
echo "Hello from EBS!" | sudo tee /data/hello.txt
Read the file
cat /data/hello.txt
You should see:
csharp
Hello from EBS!
5. Confirm Persistence After Reboot
Stop your EC2 instance
Start it again
Reconnect via SSH
bash
Remount the volume
sudo mount /dev/xvdf /data
Check your data
cat /data/hello.txt
If you see the same content, your EBS volume is functioning as persistent storage.
Real-Life Scenarios for Each EBS Feature
Feature Real-World Example
Persistent Hosting databases that need to retain logs and data after restarts
Attachable Moving a volume between EC2 instances in a failover setup
Encrypted Storing PII or compliance-sensitive data in healthcare/finance
Snapshots Creating point-in-time backups before software upgrades or patching
Bonus: Prevent EBS from Being Deleted on Termination
By default, EC2 root volumes are deleted when the instance is terminated. To retain data:
During Launch:
Scroll to Storage in the EC2 launch wizard
Uncheck "Delete on Termination"
For Existing Instances:
EC2 Dashboard → Instances → Select your instance
Go to Block Devices → Click Volume ID
Modify Delete on Termination setting from the volume details
Note: You may need to stop the instance before this setting becomes editable.
Summary
Through this project, I simulated what a cloud engineer or DevOps role would handle daily:
Creating block storage
Mounting and managing volumes
Ensuring high availability of data
Applying best practices like encryption and snapshots
This hands-on implementation validates my readiness to manage cloud infrastructure with attention to reliability, security, and scalability.
📌 Full Guide: EBS Project Handout on GitHub
🔗 Connect with Me on LinkedIn: Peter Samuel
📝 More Projects: dev.to/peter_samuel_052b9056e236
Top comments (0)