Skip to main content

Command Palette

Search for a command to run...

πŸ“¦ Understanding Amazon EBS (Elastic Block Store) β€” Simple Guide

Updated
β€’7 min read

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-1a

  • EBS 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:

  1. Create snapshot

  2. Copy/use snapshot in another AZ

  3. Create new volume

  4. 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 system

  • XFS / 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/mtab

  • Lost after reboot

Permanent Mount Configuration

  1. Copy mount entry

  2. 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/nvme0n1

  • Partition: 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.

5 views