EC2 Storage and Data Management - EBS and EFS

IntermediateTopic50 min4 min read2 May 2026AWS

Operate block and shared file storage for EC2 with EBS volumes, snapshots, encryption, resizing, EFS mount targets, and lifecycle decisions.

What you'll learn

  • Choose between EBS and EFS for EC2 workloads
  • Create, attach, mount, resize, and snapshot EBS volumes
  • Use snapshots for backup, restore, and cross-region copy
  • Mount EFS from multiple EC2 instances

Prerequisites

Relevant for certifications

SOA-C03SAA-C03

EBS vs EFS

ServiceStorage typeAttached toBest for
EBSBlock storageOne EC2 instance in one AZ at a timeBoot volumes, databases, low-latency disks
EFSManaged NFS file systemMany instances across AZsShared content, Linux home directories, shared app files

Fast decision

Use EBS when the workload needs a disk. Use EFS when multiple Linux instances need the same files at the same time.

EBS Operations

EBS volumes are AZ-scoped. An instance and its attached EBS volume must be in the same Availability Zone.

Common operations:

  • Increase volume size without stopping the instance.
  • Change volume type, such as gp2 to gp3.
  • Tune gp3 IOPS and throughput independently.
  • Snapshot a volume for backup.
  • Copy snapshots to another Region.
  • Create a new volume from a snapshot.

Snapshot Behavior

EBS snapshots are incremental after the first snapshot. Each snapshot references the blocks needed to restore the volume at that point in time.

For application-consistent backups, flush application writes, briefly freeze or stop the workload, create the snapshot, and then resume writes.

Hands-on: Add and Mount an EBS Volume

Goal: Attach a data disk to Linux and persist it across reboots.

  1. Open EC2 > Volumes and choose Create volume.
  2. Select gp3, 8 GiB, encryption enabled, and the same Availability Zone as your EC2 instance.
  3. Select the volume and choose Attach volume.
  4. Attach it to your instance as /dev/sdf.
  5. Connect to the instance and identify the device:
lsblk
  1. Create a filesystem and mount it:
sudo mkfs -t xfs /dev/xvdf
sudo mkdir -p /data
sudo mount /dev/xvdf /data
df -h
  1. Persist the mount in /etc/fstab using the volume UUID:
sudo blkid /dev/xvdf
sudo cp /etc/fstab /etc/fstab.bak
echo "UUID=<uuid> /data xfs defaults,nofail 0 2" | sudo tee -a /etc/fstab
sudo mount -a
  1. Create a test file in /data.
  2. Reboot the instance and confirm /data is mounted.

Hands-on: Resize an EBS Volume

Goal: Increase a Linux data volume from 8 GiB to 16 GiB.

  1. In EC2 > Volumes, select the volume.
  2. Choose Modify volume and change size to 16 GiB.
  3. Wait until modification state is optimizing or completed.
  4. On the instance, grow the partition if needed:
lsblk
sudo growpart /dev/xvdf 1
  1. Grow the filesystem:
# XFS
sudo xfs_growfs /data

# ext4 alternative
sudo resize2fs /dev/xvdf1
  1. Confirm with df -h.

Hands-on: Snapshot and Restore an EBS Volume

  1. Select the EBS volume and choose Create snapshot.
  2. Add tags such as Name = cloudops-data-backup.
  3. Wait for snapshot completion.
  4. Create a new volume from the snapshot in the same AZ as a test instance.
  5. Attach and mount the restored volume.
  6. Confirm the test file exists.
  7. Clean up the restored volume and old snapshots when done.

EFS Operations

EFS is regional and uses mount targets in subnets. Each mount target has an IP in a subnet and a security group.

Security group pattern:

  • EC2 security group: outbound NFS TCP 2049 to EFS security group.
  • EFS security group: inbound NFS TCP 2049 from EC2 security group.

Hands-on: Mount EFS on Two EC2 Instances

  1. Create an EFS file system.
  2. Create mount targets in at least two subnets.
  3. Configure the EFS security group to allow inbound NFS TCP 2049 from the EC2 security group.
  4. On each EC2 instance, install the EFS mount helper:
sudo dnf install -y amazon-efs-utils
  1. Mount the file system:
sudo mkdir -p /shared
sudo mount -t efs -o tls fs-1234567890abcdef0:/ /shared
  1. On instance A, create a file in /shared.
  2. On instance B, read the same file.
  3. Add an /etc/fstab entry if the mount should survive reboot.

Common SOA-C03 Exam Questions

Q: Can an EBS volume attach to an instance in another AZ? No. EBS volumes are AZ-scoped.

Q: Which service lets multiple EC2 instances share the same Linux file system? Amazon EFS.

Q: How do you copy an EBS backup to another Region? Copy the EBS snapshot to the destination Region, then create a volume from the copied snapshot.

What to Learn Next

  1. Amazon S3 for CloudOps - object storage, lifecycle, and replication
  2. AWS Disaster Recovery for CloudOps - backup and recovery patterns
  3. AWS Security & Compliance - KMS encryption and access controls

More in Amazon Web Services