Skip to main content

Command Palette

Search for a command to run...

Amazon EFS (Elastic File System)

Published
•4 min read•View as Markdown

Amazon Elastic File System (Amazon EFS) provides a simple, scalable, elastic file system for general purpose workloads for use with AWS Cloud services and on-premises resources.OR

Amazon EFS (Elastic File System) is a shared file storage service in AWS.
It allows multiple EC2 instances to access the same files at the same time.

Think of EFS like:

Google Drive for your EC2 servers.


What problem EFS solves

Without EFS:

  • Every EC2 has its own storage

  • Files are not shared

With EFS:

  • All EC2 see the same files

  • Data stays in sync


Why EFS is used

EFS is used when:

  • Many servers need same data

  • You want shared storage

  • You need scalable file system

  • You want managed NFS storage


Where EFS is used

EFS is used in:

  • Web applications

  • Media storage

  • WordPress

  • Microservices

  • CI/CD shared workspace

  • Kubernetes persistent storage

  • Big data processing


When to use EFS

Use EFS when:

  • You have multiple EC2

  • You need file sharing

  • You want automatic scaling

  • You want no disk management

Do NOT use EFS when:

  • You need very low latency block storage
    Use EBS instead

How EFS works

EC2 connects to EFS using:

  • NFS protocol

EFS is mounted like:

/mnt/efs

All servers read and write from same folder.


EFS vs EBS

FeatureEFSEBS
SharedYesNo
Used by multiple EC2YesNo
Auto scalingYesNo
Use caseShared filesOS, DB

Key features of EFS

Fully managed

AWS handles:

  • Storage

  • Replication

  • Availability


Highly available

Data is stored across:

  • Multiple Availability Zones

Auto scaling

No size planning needed
It grows and shrinks automatically


Secure

Supports:

  • Encryption

  • IAM access

  • Security groups


Performance modes

  • General Purpose

  • Max I/O


Throughput modes

  • Bursting

  • Provisioned

  • Elastic


Backup

EFS supports:

  • AWS Backup

  • Snapshots


DevOps usage

EFS is used in:

  • Kubernetes volumes

  • Jenkins shared workspace

  • Docker persistent storage

  • App log storage


Real example

You have 5 web servers
All need same images
Use EFS
Upload once
All servers see it


Pricing

You pay only for:

  • Storage used

Important interview points

  • EFS is file storage

  • Works with NFS

  • Multi AZ

  • Shared

  • Auto scaling

How to Mount EFS

Step 1: Create EFS

AWS Console → EFS → Create file system
Choose:

  • Same VPC as EC2

  • Keep defaults

After creating, note:

  • File System ID
    Example:
fs-0ab12cd3456ef7890

Step 2: Security Group setup

EFS security group must allow:

TypeProtocolPortSource
NFSTCP2049EC2 security group

EC2 security group must allow:

TypePort
SSH22
All traffic OR NFS2049

Step 3: Install EFS utils on EC2

Login to EC2.

For Amazon Linux:

sudo yum install amazon-efs-utils -y

For Ubuntu:

sudo apt install nfs-common -y

Step 4: Create mount directory

sudo mkdir /mnt/efs

Step 5: Mount EFS

Replace your file system ID:

sudo mount -t efs fs-0ab12cd3456ef7890:/ /mnt/efs

Check:

df -h

You should see EFS mounted.


Step 6: Test

cd /mnt/efs
touch test.txt
ls

If file appears, EFS is working.


Step 7: Auto mount after reboot

Edit fstab:

sudo nano /etc/fstab

Add this line:

fs-0ab12cd3456ef7890:/ /mnt/efs efs defaults,_netdev 0 0

Save and exit.

Test:

sudo mount -a

What just happened

Now:

  • EFS is connected to EC2

  • Data will persist

  • Multiple EC2 can use same EFS


Real DevOps use

This is used in:

  • Jenkins

  • WordPress

  • Kubernetes

  • Shared logs

  • Microservices

More from this blog

T

The DevOps Journal

23 posts