π¦ Understanding Amazon EBS (Elastic Block Store) β Simple Guide
1. πΎ What is Amazon EBS?
Amazon EBS (Elastic Block Store) provides persistent block storage for Amazon EC2 instances.
π In simple terms:
EBS acts like a virtual hard drive attached to your EC2 instance.
β Data persists even if the instance:
Stops
Restarts
1.1 π How EBS Works
Create an EBS volume
Attach it to an EC2 instance
Use it like a disk inside the OS
π Common uses:
Operating system (root volume)
Application data
Logs and databases
2. π EBS Performance Metrics
Understanding performance is critical for real-world workloads.
(EBS performance is evaluated using four main metrics.)
2.1 IOPS (Input/Output Operations Per Second)
IOPS represents:
- Number of read/write operations a volume can handle per second
Important:
Small I/O operations β higher IOPS demand
- Databases are IOPS-sensitive
π Example:
- 1,000 IOPS = 1,000 operations/sec
β Important for:
Databases
Transaction systems
2.2 Block Size
- Amount of data per I/O operation
Common sizes:
4 KB
8 KB
16 KB
π Impact:
Smaller block size β more IOPS
Larger block size β fewer IOPS, higher throughput
2.3 Latency
Latency is:
- Time taken to complete one I/O operation
Measured in:
- milliseconds (ms)
Lower latency = faster response Critical for:
Databases
Transaction systems
Real-time applications
2.4 Throughput
Throughput is:
- Rate at which data is transferred
Measured in:
MB/s
GB/s
Important for:
Large file processing
Data analytics
Streaming workloads
2.5 Relationship Between IOPS, Throughput, and Block Size
A simplified formula:
IOPS = (Throughput Γ 1024) / Block Size (KB)
Meaning:
Increasing block size increases throughput but reduces IOPS
Workload type decides which metric matters more
3. π¦ EBS Volume Types (Overview)
Three main categories:
SSD-backed volumes β low latency, random I/O
HDD-backed volumes β high throughput
Magnetic volumes β legacy
4. Root Volume vs Additional Volumes
Root Volume
Contains the Operating System
Mandatory for launching an EC2 instance
Without root volume β instance cannot boot
Supported root volume types:
gp2
gp3
io1
io2
Additional (Data) Volumes
Used for application data, logs, databases
Can be attached/detached independently
Supported additional volume types:
gp2, gp3
io1, io2
st1, sc1
standard (magnetic)
5. SSD-Based EBS Volumes
SSD volumes are optimized for low latency and random I/O.
5.1 General Purpose SSD β gp2 & gp3
These are the most commonly used EBS volumes.
gp2
Balanced performance
Performance scales with size
Suitable for:
Boot volumes
Web servers
Dev/Test workloads
Size range:
- 1 GB to 16 TB
gp3 (Recommended)
Decouples storage size from performance
You can independently configure:
IOPS
Throughput
Size range:
- 1 GB to 64 TiB
Why gp3 is better:
More predictable performance
Lower cost
Better control
5.2 Provisioned IOPS SSD (io1 & io2)
Used when performance must be guaranteed.
Used when exact IOPS guarantees are required.
Suitable for:
Databases
High-transaction systems
Mission-critical workloads
io1
Provision specific IOPS
Good for consistent high performance
Size range: 4 GB to 16 TB
io2
Higher durability
Higher IOPS capability
Designed for critical production systems
Key characteristics:
Minimum IOPS: 100
Maximum IOPS: up to 100,000
Size range: 4 GB to 64 TiB
6. π§± HDD-Based Volumes
HDD volumes are optimized for high throughput, not random IOPS.
6.1 Throughput Optimized HDD β st1
Best suited for:
Big data workloads
Log processing
Data warehousing
Streaming large files
Characteristics:
High MB/s throughput
Not suitable for boot volumes
Lower cost than SSD
Size range:
- 125 GB to 16 TB
6.2 Cold HDD β sc1
Designed for:
Infrequently accessed data
Cold storage
Cost-sensitive workloads
Characteristics:
Lowest performance
Lowest cost
Sequential access only
Size range:
- 125 GB to 16 TB
7. Magnetic (Standard) Volumes
Legacy storage option.
Characteristics:
Lowest cost
Lowest performance
Rarely used today
Size range:
- 1 GB to 1 TB
Used only for:
Legacy systems
Very low-cost requirements
8. π Availability Zone Limitation (Critical)
β οΈ EBS volumes are Availability Zoneβspecific
π Must match:
Region
Availability Zone
π Example:
EC2 in
us-east-1aEBS must also be in
us-east-1a
8.1 π Cross-AZ Migration (Using Snapshots)
EBS volumes cannot be moved directly across Availability Zones. To transfer an EBS volume from one zone to another, create snapshots.
β Solution: Snapshots
- Stored internally in Amazon S3
Migration Flow:
Create snapshot
Copy/use snapshot in another AZ
Create new volume
Attach to EC2
9. Linux Commands to Work with EBS Volumes
9.1 Detect Attached Volumes
lsblk
Shows:
All block devices detected by OS
Even unmounted volumes
Example volume names:
/dev/nvme0n1β root volume/dev/nvme1n1β additional volume
9.2 View Mounted File Systems
df -Th
Shows:
Mounted volumes only
File system type
Human-readable sizes
9.3 Check File System Presence
file -s /dev/nvme1n1
Output meaning:
dataβ no file systemXFS/ext4β file system exists
10. Creating File System and Mounting (Linux)
Create XFS File System
mkfs -t xfs /dev/nvme1n1
Mount the Volume
mount /dev/nvme1n1 /home/ec2-user/newvol
Temporary mount:
Stored in
/etc/mtabLost after reboot
Permanent Mount Configuration
Copy mount entry
Add it to
/etc/fstab
Example:
mount /dev/nvme1n1 /home/ec2-user/newvol
tail -1 /etc/matb
sudo vi /etc/fstab
Activate:
mount -a
11. Expanding an Existing EBS Volume
Step 1: Increase Volume Size (AWS Console)
Modify volume
Increase size (cannot decrease)
Step 2: Expand File System (Linux β XFS)
xfs_growfs -d /home/ec2-user/newvol
This updates file system to use new space.
12. Expanding Root Volume (Linux)
Step 1: Increase root volume size in AWS Console
Step 2: Identify Root Partition
Usually:
Volume:
/dev/nvme0n1Partition:
1
Step 3: Grow Partition
growpart /dev/nvme0n1 1
Step 4: Reboot Instance
reboot
File system expands after reboot.
13. β οΈ Important Limitation
β AWS does NOT support reducing EBS volume size
If you need smaller size:
Create new volume
Copy data
Replace old volume
14. π EBS vs Instance Store
| Feature | EBS | Instance Store |
|---|---|---|
| Persistence | β Yes | β No |
| Stop/Start Safe | β Yes | β No |
| Type | Network | Physical |
| Use Case | Durable storage | Temporary data |
15. β Best Practices (Real-World)
Use gp3 by default
Use io2 for databases
Avoid st1/sc1 for DBs
Separate root and data volumes
Take snapshots before changes
Monitor via Amazon CloudWatch
π Final Takeaway
Amazon EBS is a core storage service in AWS, providing:
Persistence
Scalability
Performance flexibility
But remember:
π It is tightly coupled to the Availability Zone, which impacts architecture design.
