Amazon EBS (Elastic Block Store)¶
Service Overview and Purpose¶
Amazon EBS provides high-performance block storage volumes for use with EC2 instances. EBS volumes are highly available and reliable storage volumes that can be attached to any running instance that is in the same Availability Zone. EBS volumes persist independently from the running life of an EC2 instance.
Key Characteristics¶
- Block-Level Storage: Raw block-level storage for EC2 instances
- Persistent Storage: Data persists beyond EC2 instance lifecycle
- High Availability: Replicated within an Availability Zone
- Elastic: Dynamically increase capacity and change performance
- Encrypted: Built-in encryption capabilities
Key Features and Capabilities¶
Volume Types¶
- General Purpose SSD (gp3)
- Latest generation general purpose SSD
- Baseline: 3,000 IOPS and 125 MiB/s throughput
- Configurable IOPS: Up to 16,000 IOPS
- Configurable throughput: Up to 1,000 MiB/s
- Size: 1 GiB to 16 TiB
-
Use case: Boot volumes, low-latency interactive apps
-
General Purpose SSD (gp2)
- Previous generation general purpose SSD
- Baseline: 3 IOPS per GiB (minimum 100 IOPS)
- Burst performance: Up to 3,000 IOPS
- Size: 1 GiB to 16 TiB
-
Use case: Boot volumes, development environments
-
Provisioned IOPS SSD (io2)
- Highest performance SSD
- Up to 64,000 IOPS per volume
- Up to 1,000 MiB/s throughput
- 99.999% durability (100x more than io1)
- Size: 4 GiB to 16 TiB
-
Use case: Critical business applications, databases
-
Provisioned IOPS SSD (io1)
- High performance SSD
- Up to 64,000 IOPS per volume
- Up to 1,000 MiB/s throughput
- Size: 4 GiB to 16 TiB
-
Use case: I/O intensive workloads
-
Throughput Optimized HDD (st1)
- Low-cost HDD for frequently accessed data
- Baseline: 40 MiB/s per TiB
- Burst: Up to 250 MiB/s per TiB
- Size: 125 GiB to 16 TiB
-
Use case: Big data, data warehouses, log processing
-
Cold HDD (sc1)
- Lowest cost HDD for less frequently accessed data
- Baseline: 12 MiB/s per TiB
- Burst: Up to 80 MiB/s per TiB
- Size: 125 GiB to 16 TiB
- Use case: Infrequent access, cold data
Core Features¶
Snapshots¶
- Point-in-time copies of EBS volumes
- Incremental backups stored in S3
- Cross-region copying for disaster recovery
- Automated via DLM (Data Lifecycle Manager)
- Fast Snapshot Restore for quick volume creation
Encryption¶
- Data at rest encryption using AWS KMS
- Data in transit encryption between instance and volume
- Snapshot encryption inherited from volume
- No performance impact on modern instance types
Multi-Attach¶
- Attach single volume to multiple EC2 instances
- Available for io1 and io2 volume types only
- Same Availability Zone requirement
- Cluster-aware file systems required
Elastic Volumes¶
- Modify volume size without detaching
- Change volume type while attached
- Modify IOPS on io1, io2, and gp3 volumes
- Live migration with minimal downtime
Use Cases and Scenarios¶
Primary Use Cases¶
- Database Storage
- Database files and logs
- High IOPS requirements
- Consistent performance
-
Point-in-time recovery
-
File Systems
- Boot volumes
- Application data
- Shared storage with Multi-Attach
-
Content repositories
-
Backup and Archive
- Snapshot-based backups
- Cross-region disaster recovery
- Compliance requirements
-
Long-term retention
-
Big Data Analytics
- Data lakes and warehouses
- ETL processing
- Log analysis
- Sequential read/write workloads
Architecture Patterns¶
- Database Tier
- io2 for high-performance databases
- gp3 for general purpose databases
-
Snapshot-based backup strategy
-
Application Tier
- gp3 for application servers
- st1 for log processing
-
Auto Scaling with EBS optimization
-
Backup and DR
- Cross-region snapshot copying
- Automated lifecycle management
- Point-in-time recovery
Pricing Models and Cost Optimization¶
Pricing Components¶
- Volume Storage
- Per GB per month
- Varies by volume type
-
Provisioned capacity (not used capacity)
-
IOPS Charges
- io1/io2: Provisioned IOPS
- gp3: IOPS above baseline
-
No additional charges for gp2
-
Throughput Charges
- gp3: Throughput above baseline
-
No charges for other volume types
-
Snapshot Storage
- Per GB per month in S3
- Incremental storage only
- Cross-region transfer charges
Cost Optimization Strategies¶
-
Right-Size Volumes
# Monitor volume utilization aws cloudwatch get-metric-statistics \ --namespace AWS/EBS \ --metric-name VolumeReadOps \ --dimensions Name=VolumeId,Value=vol-12345678 \ --start-time 2023-01-01T00:00:00Z \ --end-time 2023-01-02T00:00:00Z \ --period 3600 \ --statistics Average -
Optimize Volume Types
- Use gp3 instead of gp2 for cost savings
- Migrate from io1 to io2 for better durability
-
Use st1/sc1 for appropriate workloads
-
Snapshot Management
- Implement lifecycle policies
- Delete unnecessary snapshots
-
Use cross-region replication wisely
-
Instance Optimization
- Use EBS-optimized instances
- Match instance and volume performance
- Consider placement groups
Configuration Details and Best Practices¶
Volume Creation and Management¶
# Create gp3 volume
aws ec2 create-volume \
--size 100 \
--volume-type gp3 \
--iops 4000 \
--throughput 250 \
--availability-zone us-west-2a \
--encrypted \
--kms-key-id alias/aws/ebs
# Attach volume to instance
aws ec2 attach-volume \
--volume-id vol-12345678 \
--instance-id i-87654321 \
--device /dev/sdf
# Modify volume (size and performance)
aws ec2 modify-volume \
--volume-id vol-12345678 \
--size 200 \
--iops 6000 \
--throughput 500
Snapshot Management¶
# Create snapshot
aws ec2 create-snapshot \
--volume-id vol-12345678 \
--description "Database backup before upgrade"
# Copy snapshot to another region
aws ec2 copy-snapshot \
--source-region us-west-2 \
--source-snapshot-id snap-12345678 \
--destination-region us-east-1 \
--description "DR backup"
# Create volume from snapshot
aws ec2 create-volume \
--snapshot-id snap-12345678 \
--availability-zone us-west-2a \
--volume-type gp3
Best Practices¶
- Performance Optimization
- Use EBS-optimized instances
- Choose appropriate volume type for workload
- Monitor IOPS and throughput utilization
-
Consider instance store for temporary data
-
Security
- Enable encryption for sensitive data
- Use customer-managed KMS keys
- Implement proper IAM policies
-
Encrypt snapshots
-
Availability and Durability
- Regular snapshot backups
- Cross-region snapshot copying
- Monitor volume health
-
Use CloudWatch alarms
-
Cost Management
- Right-size volumes based on actual usage
- Use appropriate volume types
- Implement snapshot lifecycle policies
- Monitor and optimize regularly
File System Configuration¶
# Format new volume (Linux)
sudo mkfs -t ext4 /dev/xvdf
# Create mount point
sudo mkdir /data
# Mount volume
sudo mount /dev/xvdf /data
# Add to fstab for persistent mounting
echo '/dev/xvdf /data ext4 defaults,nofail 0 2' | sudo tee -a /etc/fstab
# Verify mount
df -h
Integration with Other AWS Services¶
Direct Integrations¶
- EC2 Integration
- Root and additional volumes
- EBS-optimized instances
- Placement groups
-
Auto Scaling integration
-
Backup Integration
- AWS Backup service
- DLM (Data Lifecycle Manager)
- Cross-region replication
-
Point-in-time recovery
-
Monitoring Integration
- CloudWatch metrics
- Systems Manager
- AWS Config
- CloudTrail logging
Data Lifecycle Manager (DLM)¶
{
"ExecutionRoleArn": "arn:aws:iam::account:role/AWSDataLifecycleManagerDefaultRole",
"Description": "Daily snapshots of production volumes",
"State": "ENABLED",
"PolicyDetails": {
"PolicyType": "EBS_SNAPSHOT_MANAGEMENT",
"ResourceTypes": ["VOLUME"],
"TargetTags": [{"Key": "Environment", "Value": "Production"}],
"Schedules": [{
"Name": "DailySnapshots",
"CreateRule": {
"Interval": 24,
"IntervalUnit": "HOURS",
"Times": ["03:00"]
},
"RetainRule": {
"Count": 7
},
"CopyTags": true
}]
}
}
Backup Strategy Integration¶
# Create backup vault
aws backup create-backup-vault \
--backup-vault-name ProductionBackups \
--encryption-key-arn arn:aws:kms:region:account:key/key-id
# Create backup plan
aws backup create-backup-plan \
--backup-plan '{
"BackupPlanName": "EBSBackupPlan",
"Rules": [{
"RuleName": "DailyBackups",
"TargetBackupVault": "ProductionBackups",
"ScheduleExpression": "cron(0 5 ? * * *)",
"StartWindowMinutes": 480,
"CompletionWindowMinutes": 10080,
"Lifecycle": {
"DeleteAfterDays": 30
}
}]
}'
Security Considerations¶
Encryption¶
- Encryption at Rest
- AWS managed keys (aws/ebs)
- Customer managed keys (CMK)
- Imported key material
-
Cross-region key usage
-
Encryption in Transit
- Automatic for supported instances
- No additional configuration required
-
NVMe and Nitro System instances
-
Key Management
# Create custom KMS key for EBS aws kms create-key \ --description "EBS encryption key" \ --key-usage ENCRYPT_DECRYPT \ --key-spec SYMMETRIC_DEFAULT # Create alias aws kms create-alias \ --alias-name alias/ebs-encryption \ --target-key-id key-id
Access Control¶
-
IAM Policies
{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": [ "ec2:CreateVolume", "ec2:AttachVolume", "ec2:DetachVolume" ], "Resource": "*", "Condition": { "StringEquals": { "ec2:Encrypted": "true" } } }] } -
Resource-Based Policies
- Snapshot sharing permissions
- Cross-account access
-
Conditional access
-
VPC Endpoints
- Private API access
- No internet gateway required
- Enhanced security posture
Monitoring and Troubleshooting¶
CloudWatch Metrics¶
Volume Metrics¶
- VolumeReadOps/VolumeWriteOps: IOPS utilization
- VolumeReadBytes/VolumeWriteBytes: Throughput utilization
- VolumeTotalReadTime/VolumeTotalWriteTime: Latency
- VolumeQueueLength: Queue depth
- VolumeThroughputPercentage: Throughput utilization
Instance Metrics¶
- EBSReadOps/EBSWriteOps: Instance-level IOPS
- EBSReadBytes/EBSWriteBytes: Instance-level throughput
- EBSIOBalance%: I/O credit balance (gp2)
- EBSByteBalance%: Throughput credit balance (gp2)
Monitoring Setup¶
# Create CloudWatch alarm for high IOPS
aws cloudwatch put-metric-alarm \
--alarm-name "EBS-High-IOPS" \
--alarm-description "EBS volume high IOPS utilization" \
--metric-name VolumeReadOps \
--namespace AWS/EBS \
--statistic Sum \
--period 300 \
--threshold 1000 \
--comparison-operator GreaterThanThreshold \
--dimensions Name=VolumeId,Value=vol-12345678
# Enhanced monitoring for instances
aws ec2 monitor-instances --instance-ids i-87654321
Common Issues and Solutions¶
- Performance Issues
- Check IOPS/throughput limits
- Verify EBS optimization
- Monitor queue depth
-
Consider volume type upgrade
-
Attachment Issues
- Verify same Availability Zone
- Check instance limits
- Verify device name availability
-
Check IAM permissions
-
Snapshot Issues
- Monitor snapshot progress
- Check S3 permissions
- Verify encryption compatibility
- Consider Fast Snapshot Restore
Troubleshooting Commands¶
# Check volume status
aws ec2 describe-volumes --volume-ids vol-12345678
# Check volume attachments
aws ec2 describe-volumes \
--filters "Name=attachment.instance-id,Values=i-87654321"
# Monitor modification progress
aws ec2 describe-volumes-modifications \
--volume-ids vol-12345678
# Check snapshot status
aws ec2 describe-snapshots \
--owner-ids self \
--filters "Name=volume-id,Values=vol-12345678"
Exam-Specific Tips and Common Scenarios¶
Key Exam Topics¶
- Volume Type Selection
- Performance requirements vs cost
- IOPS vs throughput optimization
- HDD vs SSD use cases
-
Migration between volume types
-
Backup and Recovery
- Snapshot strategies
- Cross-region disaster recovery
- Point-in-time recovery
-
Automated backup policies
-
Security and Encryption
- Encryption requirements
- Key management scenarios
- Cross-account sharing
- Compliance considerations
Common Exam Scenarios¶
- Database Performance
- Choose io2 for high-performance databases
- Use gp3 for general purpose databases
- Understand IOPS requirements
-
Consider Multi-Attach for clusters
-
Backup and DR Strategy
- Implement automated snapshots
- Cross-region snapshot copying
- Lifecycle management policies
-
Recovery time objectives
-
Cost Optimization
- Right-size volumes based on usage
- Choose appropriate volume types
- Implement snapshot lifecycle policies
-
Monitor and optimize regularly
-
Migration Scenarios
- Migrate from gp2 to gp3
- Upgrade from io1 to io2
- Volume type conversions
- Cross-AZ volume migration
Exam Tips¶
- Know the performance characteristics of each volume type
- Understand when to use Multi-Attach vs EFS
- Remember encryption inheritance from snapshots
- Know the limits for each volume type and instance
- Understand cross-region snapshot copying for DR
Hands-on Examples and CLI Commands¶
Volume Management¶
# List all volumes
aws ec2 describe-volumes
# Create encrypted gp3 volume with custom performance
aws ec2 create-volume \
--size 500 \
--volume-type gp3 \
--iops 10000 \
--throughput 500 \
--availability-zone us-west-2a \
--encrypted \
--kms-key-id alias/my-ebs-key \
--tag-specifications 'ResourceType=volume,Tags=[{Key=Name,Value=ProductionDB},{Key=Environment,Value=Production}]'
# Modify volume size and performance
aws ec2 modify-volume \
--volume-id vol-12345678 \
--size 1000 \
--iops 15000 \
--throughput 750
# Check modification progress
aws ec2 describe-volumes-modifications \
--volume-ids vol-12345678
Snapshot Operations¶
# Create snapshot with description
aws ec2 create-snapshot \
--volume-id vol-12345678 \
--description "Pre-upgrade backup $(date)" \
--tag-specifications 'ResourceType=snapshot,Tags=[{Key=Name,Value=DB-Backup},{Key=Environment,Value=Production}]'
# Enable Fast Snapshot Restore
aws ec2 enable-fast-snapshot-restores \
--availability-zones us-west-2a us-west-2b \
--source-snapshot-ids snap-12345678
# Create DLM policy
aws dlm put-lifecycle-policy \
--execution-role-arn arn:aws:iam::account:role/AWSDataLifecycleManagerDefaultRole \
--description "Production volume snapshots" \
--state ENABLED \
--policy-details file://dlm-policy.json
Performance Testing¶
# Install and run fio for performance testing
sudo yum install -y fio
# Test random read IOPS
sudo fio --name=random-read \
--ioengine=libaio \
--iodepth=32 \
--rw=randread \
--bs=4k \
--direct=1 \
--size=1G \
--numjobs=4 \
--runtime=60 \
--group_reporting \
--filename=/dev/xvdf
# Test sequential write throughput
sudo fio --name=sequential-write \
--ioengine=libaio \
--iodepth=16 \
--rw=write \
--bs=1M \
--direct=1 \
--size=1G \
--numjobs=1 \
--runtime=60 \
--group_reporting \
--filename=/dev/xvdf
This comprehensive EBS documentation provides detailed coverage of all aspects needed for AWS certification exams, including practical examples and real-world scenarios.