EFS: Shared File Storage for Linux
Mount an EFS file system across multiple EC2 instances and Lambda functions, configure performance and throughput modes, and control access with security groups.
EFS: Shared File Storage for Linux is a free AWS Solutions Architect lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Solutions Architect learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Is Amazon EFS?
Amazon Elastic File System (EFS) is a fully managed, elastic, shared POSIX file system that can be mounted by thousands of EC2 instances, Lambda functions, and ECS/EKS containers simultaneously. Unlike EBS (which attaches to a single instance), EFS provides a shared file system where all connected clients see the same files in real time. Capacity grows and shrinks automatically — you never provision storage upfront. EFS is ideal for content management, shared code repositories, home directories, and data analytics.
EFS Storage Classes
EFS offers two storage classes: EFS Standard (multi-AZ, highest availability, sub-millisecond latency) and EFS One Zone (single AZ, 47% lower cost, slightly less resilient). Within each tier, there is also an Infrequent Access (IA) variant that stores data at 92% lower cost than Standard for files that are not accessed regularly. The difference from S3: EFS is a full POSIX file system that your applications can mount — it is not an object store.
# Create an EFS file system in Standard storage class
aws efs create-file-system \
--performance-mode generalPurpose \
--throughput-mode elastic \
--encrypted \
--tags Key=Name,Value=SharedFileSystem
# One Zone (cheaper, single-AZ):
aws efs create-file-system \
--performance-mode generalPurpose \
--throughput-mode elastic \
--encrypted \
--availability-zone-name us-east-1a \
--tags Key=Name,Value=SharedFileSystemOneZoneEFS Performance Modes
EFS has two performance modes: General Purpose (default, recommended for most workloads — lowest latency, ideal for web serving, content management, home directories) and Max I/O (designed for massively parallel workloads with thousands of concurrent connections at the cost of slightly higher latency, ideal for big data and media processing). Performance mode is set at creation and cannot be changed after the file system is created. For the SAA-C03 exam, choose Max I/O only when you explicitly need thousands of parallel connections.
# Create EFS with Max I/O for highly parallel workloads
aws efs create-file-system \
--performance-mode maxIO \
--throughput-mode provisioned \
--provisioned-throughput-in-mibps 1024 \
--encrypted
# Note: Max I/O mode is NOT compatible with Elastic throughput mode
# It must use Provisioned or Bursting throughputEFS Throughput Modes
EFS supports three throughput modes: Elastic (automatically scales throughput up and down based on workload — recommended for most use cases, billed per GB transferred), Bursting (throughput scales with storage size, earns and consumes burst credits like EC2 T-series — free baseline), and Provisioned (you specify a fixed throughput regardless of storage size — useful when you need consistent throughput beyond what Bursting provides). Elastic mode is the modern default and eliminates the need to plan throughput capacity.
# Migrate an existing EFS from Bursting to Elastic throughput
aws efs update-file-system \
--file-system-id fs-0abc1234def567890 \
--throughput-mode elastic
# Check current throughput mode and performance mode
aws efs describe-file-systems \
--file-system-id fs-0abc1234def567890 \
--query 'FileSystems[].{ThroughputMode:ThroughputMode,PerfMode:PerformanceMode,SizeBytes:SizeInBytes.Value}'Mount Targets and Security Groups
To access an EFS file system from an EC2 instance, you create a mount target in each subnet (AZ) where your instances run. For EFS Standard, you should create a mount target in each AZ in your VPC — EC2 instances connect to the mount target in their own AZ for the lowest latency. Mount targets have security groups that must allow NFS traffic (port 2049 TCP) from the instance's security group. Without this inbound rule, mount operations will time out.
# Create a mount target in each AZ
aws efs create-mount-target \
--file-system-id fs-0abc1234def567890 \
--subnet-id subnet-aaa111 \
--security-groups sg-efsnfs
aws efs create-mount-target \
--file-system-id fs-0abc1234def567890 \
--subnet-id subnet-bbb222 \
--security-groups sg-efsnfs
# The EFS security group needs: Inbound TCP 2049 from instance SGMounting EFS on EC2 Linux
The recommended way to mount EFS on EC2 is using the Amazon EFS Mount Helper (amazon-efs-utils package), which supports TLS encryption in transit and automatic reconnection. You mount using the file system ID rather than the IP address so DNS resolves to the nearest AZ mount target automatically. For persistent mounts that survive reboots, add the mount entry to /etc/fstab using the _netdev option to ensure the network is available before mounting.
# Install the EFS mount helper
sudo yum install -y amazon-efs-utils
# Mount with TLS encryption in transit
sudo mkdir /mnt/efs
sudo mount -t efs -o tls fs-0abc1234def567890:/ /mnt/efs
# Persistent mount in /etc/fstab
# fs-0abc1234def567890:/ /mnt/efs efs defaults,_netdev,tls 0 0
# Verify mount
df -h /mnt/efsEFS Access Points
EFS Access Points are application-specific entry points into an EFS file system that enforce a specific POSIX user, group, and root directory for all connections using that access point. This allows multiple applications on the same file system to be isolated from each other — Application A mounts via Access Point A and only sees /data/app-a/, while Application B using Access Point B only sees /data/app-b/. Access Points are the recommended way to grant Lambda functions, ECS tasks, and EKS pods isolated access to shared EFS file systems.
# Create an EFS Access Point for an application
aws efs create-access-point \
--file-system-id fs-0abc1234def567890 \
--posix-user Uid=1001,Gid=1001 \
--root-directory Path=/data/app-a,CreationInfo={OwnerUid=1001,OwnerGid=1001,Permissions=755} \
--tags Key=App,Value=app-a
# Mount using the access point
sudo mount -t efs \
-o tls,accesspoint=fsap-0abc1234def567890 \
fs-0abc1234def567890:/ /mnt/app-aEFS Intelligent-Tiering and Lifecycle
EFS Intelligent-Tiering automatically moves files between Standard and Standard-IA (Infrequent Access) storage classes based on access patterns. You configure a lifecycle policy — for example, move files to IA after 30 days without access. When a file in IA is accessed again, it is automatically moved back to Standard. The retrieval from IA has a per-GB retrieval fee but costs significantly less for storage. This is similar to S3 Intelligent-Tiering and eliminates the need to manually manage file placement.
# Enable lifecycle management (move to IA after 14 days)
aws efs put-lifecycle-configuration \
--file-system-id fs-0abc1234def567890 \
--lifecycle-policies '[
{"TransitionToIA": "AFTER_14_DAYS"},
{"TransitionToPrimaryStorageClass": "AFTER_1_ACCESS"}
]'
# Check current lifecycle configuration
aws efs describe-lifecycle-configuration \
--file-system-id fs-0abc1234def567890EFS with Lambda and Containers
Lambda functions can mount EFS file systems to share large model files, persistent data, or configuration across invocations — overcoming the 512 MB-10 GB /tmp limit. ECS and EKS tasks mount EFS via persistent volume claims using the EFS CSI driver. The Lambda function or container must be in a VPC that has a mount target, and the EFS security group must allow inbound NFS from the Lambda or container VPC security group. EFS + Lambda is a common pattern for sharing trained ML models across function instances.
# Lambda function with EFS mount (CloudFormation excerpt)
# Resources:
# MyFunction:
# Type: AWS::Lambda::Function
# Properties:
# VpcConfig:
# SubnetIds: [subnet-aaa]
# SecurityGroupIds: [sg-lambda]
# FileSystemConfigs:
# - Arn: arn:aws:elasticfilesystem:us-east-1:111122223333:access-point/fsap-0abc
# LocalMountPath: /mnt/models
# In function code:
# import os
# model_path = '/mnt/models/my-model.pkl'
# with open(model_path, 'rb') as f:
# model = pickle.load(f)EFS vs EBS: Key Exam Differences
The SAA-C03 exam frequently asks you to choose between EFS and EBS. EFS: POSIX shared file system, mounts on multiple EC2 instances simultaneously, elastic capacity, Linux only (NFS), accessible by Lambda and containers, higher cost per GB. EBS: block device, attaches to a single EC2 instance (except io1/io2 Multi-Attach), fixed provisioned size, both Linux and Windows, not natively accessible by Lambda, lower cost per GB. If the scenario says 'multiple instances must share the same files', the answer is EFS.
EFS Encryption
EFS supports encryption at rest (enabled at file system creation using a KMS key — cannot be changed after creation) and encryption in transit (TLS encryption when using the EFS mount helper with the tls option). AWS recommends enabling both. You can enforce in-transit encryption using an EFS resource-based policy that denies mount without TLS by requiring the elasticfilesystem:ClientRootAccess and elasticfilesystem:ClientWrite conditions.
# Create an EFS file system with encryption at rest
aws efs create-file-system \
--encrypted \
--kms-key-id arn:aws:kms:us-east-1:111122223333:key/KEY_ID
# Mount with TLS to encrypt in transit
sudo mount -t efs -o tls fs-0abc1234def567890:/ /mnt/efs
# Deny unencrypted mounts via EFS resource policy (condition)
# Condition: elasticfilesystem:AccessedViaMountTarget = true
# and aws:SecureTransport = trueQuick Check
Test your understanding of AWS Solutions Architect (SAA-C03) concepts from this lesson.
Lesson Recap
In this lesson you learned: EFS is a shared POSIX file system that can be mounted on thousands of instances and Lambda functions simultaneously with elastic capacity, Access Points provide per-application isolation with enforced POSIX user and root directory, and Intelligent-Tiering automatically moves infrequently accessed files to a lower-cost IA storage class. Next up we explore FSx for Windows File Server and Lustre for specialised workloads.
Frequently asked questions
Is the “EFS: Shared File Storage for Linux” lesson free?
Yes — the full text of “EFS: Shared File Storage for Linux” is free to read here on the web, and the AWS Solutions Architect course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Solutions Architect course, upgrade to CoddyKit PRO.
What will I learn in “EFS: Shared File Storage for Linux”?
Mount an EFS file system across multiple EC2 instances and Lambda functions, configure performance and throughput modes, and control access with security groups. You practise AWS Solutions Architect with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AWS Solutions Architect?
No prior experience is required. AWS Solutions Architect on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “EFS: Shared File Storage for Linux” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AWS Solutions Architect lesson?
Yes. Every AWS Solutions Architect lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- EBS Volume Types: gp3, io2, st1, sc1
- EBS Snapshots, Encryption, and RAID
- EFS: Shared File Storage for Linux
- FSx: Windows File Server and Lustre