Sub topic 3
Restoring from Snapshots and Initializing EBS Volumes
Assume you understand EC2 instances, Availability Zones, Linux filesystems, and basic AWS CLI commands. A restored EBS volume starts from a snapshot, but its blocks may load lazily on first access.
Restore and initialize a volume
Create the volume in the same Availability Zone as the instance that will use it. After attaching it, mount the filesystem. For latency-sensitive workloads, use Fast Snapshot Restore or read the volume sequentially to initialize commonly used blocks.
REGION=us-east-1
SNAPSHOT_ID=snap-0123456789abcdef0
AZ=us-east-1b
VOLUME_ID=$(aws ec2 create-volume \
--region "$REGION" \
--snapshot-id "$SNAPSHOT_ID" \
--availability-zone "$AZ" \
--volume-type gp3 \
--query VolumeId \
--output text)
aws ec2 wait volume-available \
--region "$REGION" \
--volume-ids "$VOLUME_ID"A snapshot contains the volume's data and metadata. Restoring it creates a new volume, so the original remains unchanged.
Encrypt, automate, and monitor
Encryption protects data at rest and traffic between the instance and EBS. Encrypted snapshots produce encrypted volumes. You can use the AWS managed key or a customer managed AWS KMS key.
aws ec2 enable-ebs-encryption-by-default --region us-east-1
aws ec2 get-ebs-encryption-by-default --region us-east-1Use Amazon Data Lifecycle Manager or AWS Backup to schedule snapshots, retain only the required recovery points, and copy critical backups to another Region. Snapshot storage is incremental, but deleting a snapshot does not necessarily remove all blocks still referenced by later snapshots.
Monitor CloudWatch metrics such as VolumeReadOps, VolumeWriteOps, VolumeQueueLength, and VolumeIdleTime. A growing queue with high I/O demand can indicate insufficient provisioned performance or an instance-level EBS limit.
Multi-Attach and cost control
Multi-Attach allows supported io1 and io2 volumes to attach to multiple Nitro instances in one Availability Zone. Use a cluster-aware application and filesystem. Ordinary ext4 or XFS mounts on multiple writers can corrupt data.
| Cost driver | Control |
|---|---|
| Volume GiB, IOPS, and throughput | Right-size and retune with Elastic Volumes |
| Snapshot storage and copies | Set retention and delete obsolete recovery points |
| Fast Snapshot Restore | Enable it only in required Availability Zones |
Exercise
Why might a restored volume be slow on its first reads, and how can you reduce that effect?
Show answer
Snapshot blocks may initialize lazily. Use Fast Snapshot Restore or pre-read important data before serving production traffic.