AWS EBS and EFS

Amazon Elastic Block Store (EBS) and Amazon Elastic File System (EFS) give EC2 instances places to keep data. EBS works like a private hard drive for one server. EFS works like a shared network folder that many servers open at the same time.

A laptop with a USB drive plugged in shows the EBS idea. Only that laptop reads the drive. An office shared folder shows the EFS idea. Every employee opens the same files from their own desk.

Three Ways an EC2 Instance Stores Data

+--------------------+---------------------+---------------------+
| Instance Store     | EBS Volume          | EFS File System     |
+--------------------+---------------------+---------------------+
| Built into host    | Network disk        | Shared network      |
| Data lost on stop  | Data survives stop  | folder              |
| Very fast          | One instance        | Many instances      |
| Temporary work     | Operating system,   | Shared content,     |
|                    | databases           | web files           |
+--------------------+---------------------+---------------------+

Amazon EBS in Simple Terms

An EBS volume is a block storage disk that attaches to an EC2 instance. The instance sees the volume as a normal drive. You format it, create folders, and install software on it.

Key Facts About EBS

  • A volume lives in one Availability Zone and attaches to instances in that same zone.
  • Data stays on the volume after you stop the instance.
  • You can detach a volume and attach it to another instance in the same zone.
  • You can increase a volume size without rebuilding the server.

Common EBS Volume Types

  • General Purpose SSD (gp3) suits most workloads, including boot disks and small databases.
  • Provisioned IOPS SSD (io2) suits databases that need steady, high speed.
  • Throughput Optimized HDD (st1) suits large, sequential reads such as log processing.
  • Cold HDD (sc1) suits rarely accessed data at the lowest cost.

EBS Snapshots

A snapshot is a backup copy of a volume at a specific moment. AWS stores snapshots in durable storage managed behind the scenes. The first snapshot copies all used data. Later snapshots copy only the blocks that changed, which saves time and space.

Volume (100 GB)
     |
     +--> Snapshot 1  (full copy of used data)
     |
     +--> Snapshot 2  (only changed blocks)
     |
     +--> Snapshot 3  (only changed blocks)
              |
              v
      Restore as a new volume in any zone

Snapshots also move data between zones and regions. Create a snapshot, copy it, and build a fresh volume where you need it.

Amazon EFS in Simple Terms

EFS provides a managed file system that uses the Network File System (NFS) protocol. Linux instances mount it like a folder. The storage grows and shrinks automatically as you add and remove files, so no capacity planning is needed.

Key Facts About EFS

  • Thousands of instances can mount the same file system together.
  • Instances in different Availability Zones of one region can share it.
  • Billing follows the amount of data stored.
  • Storage classes move rarely used files to cheaper tiers.

Shared Website Example

A blog runs on three web servers behind a load balancer. Visitors upload images, and every server must show every image. EFS solves the problem because all three servers read and write one shared folder.

        Visitors
           |
     Load Balancer
     /     |     \
 Web 1   Web 2   Web 3
 (AZ-a)  (AZ-b)  (AZ-c)
     \     |     /
   EFS File System
   /uploads/images

EBS cannot fill this role in the standard setup because each volume attaches to a single instance.

EBS or EFS: Choosing the Right One

  • Pick EBS for an operating system disk or a database on one server.
  • Pick EFS for content that several servers must read and write together.
  • Pick S3 for backups, media archives, and static website files.

Security and Cost Tips

  • Turn on encryption for volumes and file systems. AWS handles the keys through KMS.
  • Use security groups to control which instances reach an EFS file system.
  • Delete unused volumes. A stopped instance with an attached volume still creates storage charges.
  • Remove old snapshots you no longer need.

Quick Practice Steps

  1. Launch a small EC2 instance in a practice account.
  2. Create an EBS volume in the same Availability Zone.
  3. Attach the volume to the instance.
  4. Format the volume and mount it to a folder.
  5. Create a snapshot, then delete every resource when you finish.

Clean-up matters. Forgotten volumes and snapshots quietly grow a bill over weeks.