Skip to Content

EBS volumes

Amazon EBS volumes are network disks for EC2 instances. They live in one AZ, are billed for their provisioned size, and can be resized live.

What it is

An Amazon EBS (Elastic Block Store) volume is a disk attached to an EC2 instance while it runs. It works like a network USB stick: the instance sees an ordinary drive, but the drive actually lives on AWS storage servers and is reached over the network.

  • Data on a volume persists independently of the instance: it survives a stop, and can survive termination too.
  • At the basic level, a volume is attached to one instance at a time. (The io1 and io2 types can be shared; see Multi-Attach.)
  • A volume belongs to one Availability Zone.

Every EC2 instance in this handbook's labs already uses one: the 8 GB root volume the operating system boots from.

How it works

EBS volumes attached to instances in us-east-1a and us-east-1b, with one 10 GB volume unattached EBS volumes attached to instances in us-east-1a and us-east-1b, with one 10 GB volume unattached

Volumes attach only to instances in their own AZ.
  • It's a network drive, not a physical disk in the server. That adds a little latency, but it means a volume can be detached from one instance and attached to another quickly.
  • It's locked to an AZ. A volume in us-east-1a can't attach to an instance in us-east-1b. To move the data, take a snapshot and restore it in the other AZ. Inside its AZ, AWS replicates the volume to protect against a single hardware failure.
  • One instance can have many volumes, like instance B above with a 100 GB and a 50 GB volume. A volume can also sit unattached, still holding its data (and still billed).
  • Capacity is provisioned: a size in GB and, for some types, IOPS and throughput. Billing is for what is provisioned, not for what is used.
  • It can grow later. Elastic Volumes increases the size, changes the type, or changes the IOPS while the volume stays attached and in use. After growing a volume, extend the file system inside the OS. Volumes can't be made smaller.

Delete on termination

Each volume attached to an instance has a Delete on termination setting, which decides what happens to it when the instance is terminated:

  • The root volume is deleted by default (setting on).
  • Other attached volumes are kept by default (setting off).

It can be changed in the console at launch, or later with the AWS CLI. Use case: keep the root volume after termination, for example to investigate a failed server.

Pricing

  • Billing is per GB-month of provisioned size, prorated by the second, whether the volume is attached or not. In us-east-1, gp3 costs about $0.08 per GB-month, so an 8 GB root volume is about $0.64 a month.
  • Some types also charge for provisioned IOPS and throughput above a free baseline (see Volume types).
  • Snapshots are billed separately.

Updated since the slides

The slides call a volume "only mountable to one instance at a time (at the CCP level)". That's still the rule for most types; io1 and io2 volumes can be shared with Multi-Attach, covered on its own page. AWS has also added the Recycle Bin for EBS volumes, so a deleted volume can be recovered for up to 7 days if a rule is set up first.

Exam tips

  • "Persistent block storage for an EC2 instance" → EBS.
  • "Move an EBS volume to another AZ" → snapshot, then create a volume from it in the other AZ.
  • "Keep the root volume when the instance is terminated" → turn off Delete on termination for it.
  • "Increase disk size without downtime" → Elastic Volumes (then grow the file system).

Common traps

  • "Attach the volume to an instance in another AZ." Not possible; snapshot and restore.
  • "You pay only for the GB you've written." EBS bills the full provisioned size.
  • "Shrink the volume to save money." Volumes can only grow; to shrink, copy the data to a new, smaller volume.

Hands-on lab: add a data volume

Goal: create a volume, attach it to an instance, put a file system on it, and move it to another instance.

Costs money

A 10 GB gp3 volume costs about $0.80 a month, prorated (well under a cent for an hour). Plus one or two t3.micro instances at about $0.02 an hour each.

Launch an instance and note its AZ

Launch a t3.micro called saa-ebs, Amazon Linux 2023, key pair saa-lab-key, tag Project=saa-lab. On its Networking tab, note the Availability Zone, for example us-east-1a.

Create a volume

Open Elastic Block Store → Volumes → Create volume: type gp3, size 10 GiB, the same AZ as the instance, tag Project=saa-lab. Create.

Attach it

Select the volume, Actions → Attach volume, choose saa-ebs. Its state changes to In-use.

Format and mount it

Connect with EC2 Instance Connect and run:

lsblk                                  # the new 10G disk, e.g. nvme1n1
sudo mkfs -t xfs /dev/nvme1n1          # create a file system (only on a new, empty disk)
sudo mkdir /data && sudo mount /dev/nvme1n1 /data
echo "hello from EBS" | sudo tee /data/hello.txt
df -h /data

Detach and look

Run sudo umount /data, then in the console Actions → Detach volume. The volume shows Available: its data is still there, waiting for an instance in the same AZ.

Expected result: a second disk on the instance, holding a file, that can be detached and kept independently of the instance.

Clean up: delete the volume (Actions → Delete volume) and terminate saa-ebs. Check Volumes for any Available volumes left behind: they keep billing.

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt