EBS volumes: gp3 vs io2, snapshots and resizing without downtime
-
Phase 0: Before you start
-
Phase 1: The foundation
-
Phase 2: Operations and security
-
Phase 3: SQL Server on AWS
-
Phase 4: Troubleshooting step by step
-
Phase 5: Final project and career
Every EC2 server keeps its operating system and data on network disks called EBS volumes. This lesson on AWS EBS volumes covers the volume types, how snapshots work and how to grow a disk while the server is still running, and that last one is a request you’ll get again and again as a cloud engineer.
You’ll add a 10 GiB gp3 data disk to a private server, put a file system on it, take a snapshot and grow it to 20 GiB live. Then you’ll make the two mistakes that catch most people: changing a volume twice in a row, and restoring it into the wrong zone.
| Time | You need | By the end you can |
|---|---|---|
| 60 minutes (server and endpoints running for under an hour) | saat-vpc, saat-ec2-ssm-profile and saat-endpoint-sg from Lesson 13, your laptop signed in with aws login --profile saat-admin and the Session Manager plugin. Cost: about USD 0.10 if you clean up within an hour. | Pick between gp3, gp2 and io2, attach and mount a new volume, take and restore snapshots, resize a volume while it’s in use, and stay clear of zone and rate-limit errors. |
What it is, in one line
AWS EBS volumes are network disks for EC2 that sit in one Availability Zone, can be resized while running and are backed up with snapshots.
In Simple Words
External hard disks in a hotel room
Think of the server as a hotel room and EBS volumes as external hard disks you plug into it. You can plug in more of them, carry one to another room on the same floor, or ask for a bigger one without ever leaving the room. A snapshot is a photocopy of a disk that goes into the hotel safe; the first copy takes a while, and after that only the changed pages get copied, so if a disk breaks you make a new one from the photocopy. The one catch is that a disk only plugs into rooms on its own floor, and that floor is the Availability Zone.
Engineer's View
How EBS really works
An EBS volume is block storage that’s replicated inside one Availability Zone. It attaches to one instance at a time in the same zone (Multi-Attach for io1/io2 is the exception). On Nitro instances volumes show up as NVMe devices, so the /dev/sdf you ask for usually appears as /dev/nvme1n1.
gp3 gives you 3,000 IOPS and 125 MiB/s no matter how big it is, and you can pay for more, up to 80,000 IOPS and 2,000 MiB/s, on volumes up to 64 TiB. gp2 links performance to size (3 IOPS per GiB, minimum 100) and bursts on credits. io2 Block Express is meant for busy databases, with up to 256,000 IOPS and 99.999% durability. The HDD types (st1, sc1) are fine for large sequential reads but never for boot disks.
With Elastic Volumes you can change the size, type, IOPS and throughput of a volume while it’s in use, but after one change you have to wait at least 6 hours before changing that volume again. Growing the volume also doesn’t grow the file system; you do that yourself inside the OS, with xfs_growfs or resize2fs on Linux, or Disk Management or Resize-Partition on Windows.
You can’t shrink a volume.
Snapshots are point-in-time, incremental copies kept in S3 behind the scenes, and they belong to a Region. From a snapshot you can create a new volume in any zone of that Region, copy it to another Region, and protect it from deletion with Recycle Bin rules. Data volumes you add yourself are not deleted when the instance terminates unless you set DeleteOnTermination.
How it works, step by step
Here’s what a data disk goes through, from creation to resize.
1Create the volume in the server’s zone
In the same zone as the instance (ap-south-1a), encrypted and tagged.
2Attach, format, mount
Attach it, make a file system on it once, mount it, and add it to /etc/fstab by UUID with nofail so a missing disk can never stop the server from booting.
3Snapshot before you change anything
A snapshot starts in seconds and finishes in the background, and it’s your undo button if the change goes wrong.
4Grow it while it runs
There are two steps: one in AWS, one in the operating system.
Because of the 6-hour rule, experienced engineers put size, type, IOPS and throughput into a single modify-volume call instead of making the changes one by one.
✅ Checkpoint: You can say what gp3 gives you at no extra cost, why a volume has to be in its server’s zone, and why xfs_growfs comes after modify-volume.
Hands-on lab: AWS EBS volumes, snapshot and live resize
Before you run any command, double-check it
Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.
Start the way you usually do. In step 1 you’ll also save two small helper scripts for the Session Manager endpoints from Lesson 13, so later lessons can switch them on and off with a single line.
cd C:\aws-lab
aws login --profile saat-admin
$env:AWS_PROFILE = 'saat-admin'
$env:Path += ';C:\Program Files\Amazon\SessionManagerPlugin\bin'
$v = Get-Content C:\aws-lab\saat-vpc.json | ConvertFrom-Json1Save the endpoint helper scripts and start the endpoints
Paste this whole block:
@'
$v = Get-Content C:\aws-lab\saat-vpc.json | ConvertFrom-Json
$running = aws ec2 describe-vpc-endpoints --filters "Name=tag:lesson,Values=endpoints" "Name=vpc-endpoint-state,Values=pending,available" --query "VpcEndpoints[].VpcEndpointId" --output text
if ($running) { $running -split '\s+' | Set-Content C:\aws-lab\ssm-endpoints.txt; "SSM endpoints already running"; return }
$eps = foreach ($svc in 'ssm','ssmmessages','ec2messages') {
aws ec2 create-vpc-endpoint --vpc-id $v.VpcId --vpc-endpoint-type Interface --service-name "com.amazonaws.ap-south-1.$svc" --subnet-ids $v.PrivateA --security-group-ids $v.EndpointSg --private-dns-enabled --tag-specifications "ResourceType=vpc-endpoint,Tags=[{Key=Name,Value=saat-$svc-endpoint},{Key=course,Value=saatvedha-aws},{Key=lesson,Value=endpoints}]" --query VpcEndpoint.VpcEndpointId --output text
}
$eps | Set-Content C:\aws-lab\ssm-endpoints.txt
do { Start-Sleep 20; $s = aws ec2 describe-vpc-endpoints --vpc-endpoint-ids $eps --query "VpcEndpoints[].State" --output text } until (($s -split '\s+' | Where-Object { $_ -ne 'available' }).Count -eq 0)
"SSM endpoints ready"
'@ | Set-Content C:\aws-lab\Start-SsmEndpoints.ps1
@'
if (-not (Test-Path C:\aws-lab\ssm-endpoints.txt)) { "SSM endpoints already deleted"; return }
$eps = Get-Content C:\aws-lab\ssm-endpoints.txt
aws ec2 delete-vpc-endpoints --vpc-endpoint-ids $eps | Out-Null
Remove-Item C:\aws-lab\ssm-endpoints.txt
"SSM endpoints deleted"
'@ | Set-Content C:\aws-lab\Stop-SsmEndpoints.ps1
.\Start-SsmEndpoints.ps1After two or three minutes you should see:
SSM endpoints ready2Launch data01 and wait for Session Manager
Paste this whole block:
$ami = aws ssm get-parameter --name /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64 --query Parameter.Value --output text
$id = aws ec2 run-instances --image-id $ami --instance-type t3.micro --subnet-id $v.PrivateA --security-group-ids $v.AppSg --iam-instance-profile Name=saat-ec2-ssm-profile --metadata-options HttpTokens=required --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=data01},{Key=course,Value=saatvedha-aws},{Key=lesson,Value=14}]' 'ResourceType=volume,Tags=[{Key=course,Value=saatvedha-aws},{Key=lesson,Value=14}]' --query "Instances[0].InstanceId" --output text
do { Start-Sleep 20; $ping = aws ssm describe-instance-information --filters "Key=InstanceIds,Values=$id" --query "InstanceInformationList[0].PingStatus" --output text } until ($ping -eq 'Online')
"data01 $id is $ping"3Create and attach a 10 GiB gp3 volume
Paste this whole block:
$vol = aws ec2 create-volume --availability-zone ap-south-1a --size 10 --volume-type gp3 --encrypted --tag-specifications 'ResourceType=volume,Tags=[{Key=Name,Value=data01-data},{Key=course,Value=saatvedha-aws},{Key=lesson,Value=14}]' --query VolumeId --output text
aws ec2 wait volume-available --volume-ids $vol
aws ec2 attach-volume --volume-id $vol --instance-id $id --device /dev/sdf --query State --output text
aws ec2 wait volume-in-use --volume-ids $vol
aws ec2 describe-volumes --volume-ids $vol --query "Volumes[0].[VolumeType,Size,Iops,Throughput,Encrypted]" --output textYou should see something like this:
attaching
gp3 10 3000 125 True4Format and mount it inside the server
Open a session with aws ssm start-session --target $id, then type this at the sh-5.2$ prompt:
lsblk -l -o NAME,SIZE,MOUNTPOINTS
sudo mkfs -t xfs /dev/nvme1n1
sudo mkdir /data
sudo mount /dev/nvme1n1 /data
echo "UUID=$(sudo blkid -s UUID -o value /dev/nvme1n1) /data xfs defaults,nofail 0 2" | sudo tee -a /etc/fstab
echo "order 1001" | sudo tee /data/orders.txt
df -h /data | tail -1The last line should show something like this:
/dev/nvme1n1 10G 104M 9.9G 2% /dataBefore you format anything, check in the lsblk list that nvme1n1 is the 10G disk, because formatting the wrong device wipes it. Keep the session open.
5Take a snapshot
Back in PowerShell, run this:
$snap = aws ec2 create-snapshot --volume-id $vol --description "data01-data before resize" --tag-specifications 'ResourceType=snapshot,Tags=[{Key=course,Value=saatvedha-aws},{Key=lesson,Value=14}]' --query SnapshotId --output text
aws ec2 wait snapshot-completed --snapshot-ids $snap
aws ec2 describe-snapshots --snapshot-ids $snap --query "Snapshots[0].[SnapshotId,State,VolumeSize]" --output textYou should see something like this:
snap-0c1d2e3f4a5b60718 completed 106Grow the volume to 20 GiB while it runs
Run this:
aws ec2 modify-volume --volume-id $vol --size 20 --query "VolumeModification.ModificationState" --output text
do { Start-Sleep 10; $st = aws ec2 describe-volumes-modifications --volume-ids $vol --query "VolumesModifications[0].ModificationState" --output text } until ($st -in 'optimizing','completed')
$stYou should see this:
modifying
optimizingIn the session, grow the file system:
lsblk -l -o NAME,SIZE,MOUNTPOINTS
df -h /data | tail -1
sudo xfs_growfs /data | tail -1
df -h /data | tail -1
cat /data/orders.txtYou should see something like this:
NAME SIZE MOUNTPOINTS
nvme0n1 8G
nvme0n1p1 8G /
nvme0n1p127 1M
nvme0n1p128 10M /boot/efi
nvme1n1 20G /data
/dev/nvme1n1 10G 104M 9.9G 2% /data
data blocks changed from 2621440 to 5242880
/dev/nvme1n1 20G 176M 20G 1% /data
order 1001The disk showed 20G as soon as AWS reached optimizing, but the file system stayed at 10G until you ran xfs_growfs, and your file wasn’t touched at any point.

7Compare gp2 and gp3 for different sizes
Back in PowerShell, paste this whole block:
foreach ($gib in 20, 100, 1000, 4000) {
[pscustomobject]@{ SizeGiB = $gib; Gp2Iops = [math]::Max(100, [math]::Min(16000, 3 * $gib)); Gp3IncludedIops = 3000 }
} | Format-TableYou should see this:
SizeGiB Gp2Iops Gp3IncludedIops
------- ------- ---------------
20 100 3000
100 300 3000
1000 3000 3000
4000 12000 3000Small gp2 disks are slow unless they’re bursting. gp3 gives 3,000 IOPS at any size, and you only pay for more when a big disk needs it.
✅ Checkpoint: data01 has a 20 GiB gp3 data disk mounted at /data with orders.txt still there, plus a completed snapshot taken before the resize. Keep it all for the break lab.
Break It, Then Fix It
Two EBS rules the console won’t warn you about until you’ve broken them.
1Break it: change the volume again straight away
Ask for more IOPS on the volume you resized a moment ago:
aws ec2 modify-volume --volume-id $vol --iops 4000You’ll get this error (something like this):
An error occurred (VolumeModificationRateExceeded) when calling the ModifyVolume operation: You've reached the maximum modification rate per volume limit. Wait at least 6 hours between modifications per EBS volume.
Fix: for the next 6 hours there isn’t one, which is why you plan changes together, like --size 20 --iops 4000 --throughput 250 in one call. If it’s an emergency, create a new volume from a snapshot with the settings you need and swap it in.
2Break it: restore a snapshot in the wrong zone
Create a volume from the snapshot in ap-south-1b and try attaching it to data01, which is in ap-south-1a:
$restored = aws ec2 create-volume --availability-zone ap-south-1b --snapshot-id $snap --volume-type gp3 --tag-specifications 'ResourceType=volume,Tags=[{Key=course,Value=saatvedha-aws},{Key=lesson,Value=14}]' --query VolumeId --output text
aws ec2 wait volume-available --volume-ids $restored
aws ec2 attach-volume --volume-id $restored --instance-id $id --device /dev/sdgYou’ll get this error (something like this):
An error occurred (InvalidVolume.ZoneMismatch) when calling the AttachVolume operation: The volume 'vol-0b1c2d3e4f5a60718' is not in the same availability zone as instance 'i-0a9b8c7d6e5f40312'A snapshot belongs to the Region but a volume belongs to one zone. Fix: create the volume in the instance’s zone:
aws ec2 delete-volume --volume-id $restored
$restored = aws ec2 create-volume --availability-zone ap-south-1a --snapshot-id $snap --volume-type gp3 --tag-specifications 'ResourceType=volume,Tags=[{Key=course,Value=saatvedha-aws},{Key=lesson,Value=14}]' --query VolumeId --output text
aws ec2 wait volume-available --volume-ids $restored
aws ec2 attach-volume --volume-id $restored --instance-id $id --device /dev/sdg --query State --output textIn the session, mount the copy read-only. You need the nouuid option because the copy has the same XFS ID as /data:
sudo mkdir /restore
sudo mount -o ro,nouuid /dev/nvme2n1 /restore
cat /restore/orders.txtYou should see this:
order 10013Clean up
Type exit in the session, then paste this whole block into PowerShell:
aws ec2 terminate-instances --instance-ids $id | Out-Null
aws ec2 wait instance-terminated --instance-ids $id
aws ec2 describe-volumes --volume-ids $vol $restored --query "Volumes[].[VolumeId,State]" --output text
aws ec2 delete-volume --volume-id $vol
aws ec2 delete-volume --volume-id $restored
aws ec2 delete-snapshot --snapshot-id $snap
.\Stop-SsmEndpoints.ps1
.\Find-LabResources.ps1Before you delete them, the describe line shows something like this:
vol-0a1b2c3d4e5f60718 available
vol-0b1c2d3e4f5a60718 availableBoth data volumes are still there after the termination, because volumes you add yourself are kept unless DeleteOnTermination is set. That’s how forgotten volumes quietly pile up on real bills.
✅ Checkpoint: You hit the 6-hour rule and the zone rule, read the copy made from the snapshot, and deleted the instance, both volumes, the snapshot and the endpoints.
This happened at work
1,200 disks nobody owned
A gaming company noticed its AWS bill climbing month after month while the number of servers stayed flat. When someone finally did a cost review, they found about 1,200 EBS volumes sitting in the available state, attached to nothing. Most were data disks from test servers terminated over three years, and each termination had left its extra volumes behind. On top of that a script was taking daily snapshots of every volume and never deleting any, so there were more than 200,000 snapshots. Between them, the orphaned volumes and snapshots cost more than all the running servers.
What the team did next was fairly plain. They tagged everything with an owner, gave two weeks’ notice and then deleted unattached volumes (taking a final snapshot of anything unclear), and moved the snapshot schedules to Amazon Data Lifecycle Manager keeping 7 daily and 4 weekly copies. Now an AWS Config rule flags unattached volumes older than 14 days, and a Recycle Bin rule holds deleted snapshots for 7 days in case someone wants one back.
Common mistakes and troubleshooting
| Mistake | What happens | What to do |
|---|---|---|
| Creating a volume in a different zone from the server | InvalidVolume.ZoneMismatch | Create it in the instance’s zone; a snapshot can restore to any zone |
| Changing size, then IOPS, then throughput | VolumeModificationRateExceeded for 6 hours | Make all the changes in one modify-volume call |
| Growing the volume but not the file system | df still shows the old size | xfs_growfs or resize2fs (growpart first if partitioned) |
| Mounting by device name in fstab | Server may fail to boot when device names change | Mount by UUID with nofail |
| Formatting the wrong device | Data destroyed | Check lsblk sizes and names before mkfs |
| Forgetting added volumes after terminate | Unattached volumes keep charging | Delete them, or set DeleteOnTermination |
| Keeping gp2 out of habit | Slow small disks, burst credit surprises | Use gp3; migrate gp2 with modify-volume |
Interview questions
Click a question to open it. They’re worded the way an interviewer would ask them, and under each one you’ll find why they ask it and one way to answer, which you should put in your own words.
Fresher level
1. How would you explain an EBS volume to someone who has only used a laptop hard disk?
Why they ask this: It checks basic storage knowledge, and knowing that EBS is tied to one zone explains a lot of design choices later on.
How you might answer: I’d say it’s a disk for your EC2 instance that lives on the network instead of inside the server. It’s copied within one Availability Zone, it keeps its data even if the instance goes away, and it can only attach to an instance in that same zone.
2. You find a lot of old gp2 volumes in an account. Why might you move them to gp3?
Why they ask this: They want to see you think about cost and performance in practice, since this is one of the easiest savings in most accounts.
How you might answer: With gp2, performance depends on size at 3 IOPS per GiB, and small volumes live on burst credits. gp3 gives 3,000 IOPS and 125 MiB/s at any size and lets me buy more of each separately, so gp3 usually works out cheaper and far more predictable.
3. Can you explain in simple words what an EBS snapshot is?
Why they ask this: It’s backup basics. Most EC2 backups and restores are built on snapshots.
How you might answer: It’s a point-in-time copy of a volume. It’s incremental, so after the first one only changed blocks are stored, and AWS keeps it at the Region level, which means I can build a new volume from it in any zone of that Region or copy it to another Region.
2–5 years experience
4. A Linux server is running out of disk space and you can’t take it down. How would you add space?
Why they ask this: It’s an everyday ops task, and they want to see you do it safely. Mentioning the snapshot first tells them you have good habits.
How you might answer: I’d take a snapshot first. Then I’d run modify-volume with the new size and wait for the volume to reach optimizing, grow the partition with growpart if there is one, and finish with xfs_growfs or resize2fs. No reboot needed.
5. A database team asks for io2 volumes. When would you agree, and when would you push back?
Why they ask this: They want to see your judgement on database storage, because io2 often gets requested when gp3 would do the job.
How you might answer: I’d say yes if the database needs very high or very steady IOPS beyond what gp3 can do, or needs 99.999% durability or Multi-Attach. Otherwise I’d suggest gp3 with extra provisioned IOPS, because plenty of databases run fine on it and it costs less.
6. You restored a volume from a snapshot, and the app is slow for the first hour. Why does that happen?
Why they ask this: They’re checking you understand what happens under the hood during a snapshot restore, which matters a lot in the middle of an incident.
How you might answer: Blocks are pulled from snapshot storage the first time they’re read, which is called lazy loading, so early reads are slow. When restore speed matters I’d use Fast Snapshot Restore, or read every block once with something like fio or dd before the app goes live.
Senior level
7. You’re asked to design EBS backup and retention for 300 servers. What would you put in place?
Why they ask this: It’s operational design at scale. Backups nobody tests and snapshots nobody cleans up are both very common.
How you might answer: I’d set up tag-based policies in Amazon Data Lifecycle Manager or AWS Backup with daily and weekly retention and cross-Region copies for DR, Recycle Bin rules against accidental deletes, and KMS encryption on everything. We’d also run restore tests regularly, and reports on unattached volumes and old snapshots would keep the cost in check.
8. The DBA says a database server has high disk latency. How would you check whether EBS is the problem?
Why they ask this: It’s performance troubleshooting, and a senior engineer knows the instance can be the bottleneck as well as the volume.
How you might answer: I’d start with the volume’s CloudWatch metrics, like VolumeReadOps, VolumeWriteOps, VolumeQueueLength and the latency ones, and also look at EBSIOBalance% and EBSByteBalance% on the instance in case it’s hitting instance-level limits. Once I know whether it’s the volume or the instance type holding things back, I’d raise gp3 IOPS and throughput, move to io2, or pick an instance with more EBS bandwidth.
Quick quiz
Q1. How many IOPS does a gp3 volume include at any size?
- 100
- 1,000
- 3,000
- 16,000
Show answer
C: gp3 includes 3,000 IOPS and 125 MiB/s whatever size it is.
Q2. After modify-volume grows a disk, what else must you do on Linux?
- Nothing
- Reboot
- Grow the file system (for example xfs_growfs)
- Create a new instance
Show answer
C: AWS grows the block device, but the OS has to grow the file system.
Q3. Attaching a volume fails with InvalidVolume.ZoneMismatch. Why?
- The volume is encrypted
- The volume and instance are in different Availability Zones
- The volume is too large
- The snapshot is incomplete
Show answer
B: A volume can only attach to an instance in its own zone.
Q4. How long must you wait between modifications of the same volume?
- 1 minute
- 1 hour
- 6 hours
- 24 hours
Show answer
C: EBS allows one modification per volume every 6 hours.
Q5. What happens to a data volume you attached yourself when the instance is terminated?
- Always deleted
- Kept unless DeleteOnTermination is set
- Moved to S3
- Converted to a snapshot
Show answer
B: Volumes you add are kept by default, so you have to delete them yourself.
Quick recap
- An EBS volume lives in one zone, while a snapshot belongs to the Region and can restore to any zone.
- gp3 gives 3,000 IOPS and 125 MiB/s at any size (up to 80,000 IOPS and 2,000 MiB/s); io2 Block Express for the busiest databases.
- To resize live, run modify-volume, wait for optimizing, then grow the file system, and remember it’s one change per 6 hours.
- Mount data disks by UUID with nofail, and check lsblk before you run mkfs.
- Volumes and snapshots you added outlive the instance and keep charging until you delete them. Start-SsmEndpoints.ps1 and Stop-SsmEndpoints.ps1 are saved for later labs.
Next lesson
Lesson 15: AMIs and launch templates → You’ll turn a configured server into your own image and launch matching copies from a template.
Further reading: AWS EBS volumes
Want to go deeper into AWS EBS volumes? Read Amazon EBS volume types and Modify a volume using Amazon EBS Elastic Volumes. You can also see the full plan for this course on the AWS Cloud Administration course page.
