Amazon Elastic Compute Cloud (EC2)

EC2 Real Life Problems and Solutions

Disk partition management snapshots

In this article, we explore how to manage disk partitions on AWS EC2 instances. By separating the operating system (OS) from application data into distinct partitions—and, crucially, onto separate EBS volumes—you minimize the risk of data loss if the OS partition becomes corrupted, and you simplify recovery.

Warning

Always ensure you have proper backups before resizing or modifying partitions. Unexpected interruptions can lead to data loss.

Choosing the Right EBS Volume Type

Selecting the appropriate EBS volume type is critical for meeting your performance requirements. AWS offers SSD-backed volumes with varying baseline throughput and IOPS:

Volume TypeUse CaseBaseline IOPS
gp3Balanced cost and performanceUp to 16,000
gp2General-purpose workloads3 IOPS/GiB
io1High-performance databasesUp to 64,000
io2Mission-critical applicationsUp to 64,000

The image illustrates EBS disk partitioning, showing a pie chart with sections for OS and data volumes, and lists volume types such as gp3, gp2, io2, and io1.

Note

gp3 volumes let you provision IOPS and throughput independently, often yielding cost savings for variable workloads.

Scheduling Point-in-Time Recovery with EBS Snapshots

To guarantee point-in-time recovery of your data, schedule regular EBS snapshots. A snapshot captures the exact state of a volume at the moment it’s taken, enabling you to restore data to that precise point.

Automating Snapshot Creation

Use Amazon Data Lifecycle Manager (DLM) or AWS Backup to automate snapshot schedules:

# Create a lifecycle policy for daily snapshots
aws dlm create-lifecycle-policy \
  --description "Daily snapshot policy for critical volumes" \
  --state ENABLED \
  --resource-types VOLUME \
  --schedules "Name=DailySchedule,CopyTags=true,TagsToAdd=[{Key=Backup,Value=Daily}],CreateRule={Interval=24,IntervalUnit=HOURS}"

Restoring from a Snapshot

# Restore a volume from a snapshot
aws ec2 create-volume \
  --availability-zone us-west-2a \
  --snapshot-id snap-1234567890abcdef0 \
  --volume-type gp3 \
  --tag-specifications 'ResourceType=volume,Tags=[{Key=Name,Value=RestoredVolume}]'

References

Watch Video

Watch video content

Practice Lab

Practice lab

Previous
Mandatory best practice Part 2