Skip to content
Kuza Ndoto Academy

EBS & EFS

Beginner → IntermediateChapter 4 · Page 16 of 304 min readUpdated 15 Nov 2026

EC2 instances need disks. Amazon EBS provides block storage volumes that behave like a hard drive attached to one server, and Amazon EFS provides a shared file system that many servers can use at once. Knowing which to use, and how they differ from S3, is a core cloud skill.

Block, file and object storage

TypeAWS serviceHow you use itTypical use
BlockEBSA raw disk you format and mount on one instanceOperating system disks, databases you run yourself
FileEFS (and FSx)A shared folder mounted over the network by many instancesShared uploads, content management systems, home directories
ObjectS3Whole files over an HTTP APIMedia, backups, data lakes, static websites

Amazon EBS

An EBS volume lives in one Availability Zone and attaches to an instance in that same AZ. Data survives stopping the instance, and the volume can be detached and attached to another instance. Most volumes attach to one instance at a time (io1 and io2 volumes support a special Multi-Attach mode).

Volume typeKindUse it for
gp3General purpose SSDThe default: boot disks and most workloads; performance can be set separately from size
io2 Block ExpressProvisioned IOPS SSDDemanding databases needing consistent high performance
st1Throughput-optimised HDDLarge sequential workloads such as log processing
sc1Cold HDDRarely accessed data at the lowest EBS price

Adding a data volume

Create a 20 GiB gp3 volume in the same AZ as your instance and attach it (IDs are placeholders):

aws ec2 create-volume --availability-zone eu-west-1a --size 20 \
    --volume-type gp3 --encrypted \
    --tag-specifications "ResourceType=volume,Tags=[{Key=Name,Value=shop-data}]"
aws ec2 attach-volume --volume-id vol-0123456789abcdef0 \
    --instance-id i-0abc1234def567890 --device /dev/sdf

Then, on the instance, find, format and mount it. On modern instances the volume appears as an NVMe device. Example output, shortened:

lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS nvme0n1 259:0 0 8G 0 disk └─nvme0n1p1 259:1 0 8G 0 part / nvme1n1 259:4 0 20G 0 disk
sudo mkfs -t xfs /dev/nvme1n1
sudo mkdir /data
sudo mount /dev/nvme1n1 /data
df -h /data
Warning

mkfs erases everything on the device. Only run it on a brand-new, empty volume, and double-check the device name. To mount automatically after a reboot, add an entry to /etc/fstab using the volume's UUID.

Snapshots

A snapshot is a point-in-time backup of a volume, stored redundantly within the Region. Snapshots are incremental: after the first, only changed blocks are saved. You can create a new volume from a snapshot in any AZ of the Region, or copy it to another Region for disaster recovery.

aws ec2 create-snapshot --volume-id vol-0123456789abcdef0 \
    --description "shop-data before upgrade"

Automate snapshots with Amazon Data Lifecycle Manager or AWS Backup rather than relying on memory.

Note

Some instance types also have instance store: very fast disks physically attached to the host. Their data is lost when the instance stops or terminates, so use them only for caches and temporary data.

Amazon EFS

EFS is a managed NFS file system for Linux. It grows and shrinks automatically as you add and remove files, and you pay for what you store. Its key advantage: instances in several AZs can mount it at the same time. You create mount targets in each AZ, and instances connect to the one in their own AZ.

Availability Zone a Availability Zone b EC2 A EBS volume EC2 B EC2 C EFS mount target EFS mount target Amazon EFS file system (Regional, shared)
Figure 1. The EBS volume belongs to one AZ and one instance. The EFS file system is Regional: all three instances, in two AZs, read and write the same files through mount targets.

On Amazon Linux, install the EFS mount helper and mount the file system (the ID is a placeholder; the instance's security group must be allowed to reach the mount target on NFS port 2049):

sudo dnf install -y amazon-efs-utils
sudo mkdir -p /mnt/uploads
sudo mount -t efs -o tls fs-0123456789abcdef0:/ /mnt/uploads
Example

A county government runs its document portal on three EC2 instances in an Auto Scaling group. Citizens upload scanned forms. If uploads went to each server's EBS disk, a form uploaded to server A would be missing on server B. Mounting one EFS file system on all servers (or, often better, storing uploads in S3) solves this.

EFS offers storage classes (Standard, Infrequent Access and Archive) with lifecycle management to move cold files automatically. For Windows file shares, high-performance computing or NetApp and ZFS features, look at the Amazon FSx family.

Costs to watch

Warning

EBS charges for the provisioned size of each volume per GB-month, whether you use the space or not, and whether the instance is running or stopped. Unattached "available" volumes left behind after terminating instances, and old snapshots, quietly add up. Check EC2 → Volumes and Snapshots after practice sessions. EFS charges for the storage you actually use, plus some throughput and access charges.

Key points

  • EBS is block storage for one instance in one AZ; gp3 is the default type.
  • Snapshots back up EBS volumes incrementally and can be copied across Regions.
  • EFS is a shared, elastic NFS file system that instances in many AZs can mount together.
  • Instance store is fast but temporary.
  • Delete unused volumes and snapshots, because provisioned EBS storage is always billed.
Up next · Storage & DatabasesAmazon RDSManaged relational databases (MySQL, PostgreSQL and more).
→

Tip: use the ← and → keys to move between pages.