Amazon EFS (Elastic File System) is a managed, shared network file system that many Linux EC2 instances can mount at the same time over NFS. To use amazon efs mount ec2 setups, you create a file system, add a mount target in each subnet, allow TCP port 2049 in a security group, install amazon-efs-utils on the instance and run mount -t efs. Storage grows and shrinks automatically, and you pay for what you store.
EBS gives one instance a private disk. EFS gives a fleet one shared directory, which is why it suits web content, shared uploads, home directories and container storage.
EFS speaks NFS version 4.1 and 4.0 and is POSIX compliant, so applications see normal files, permissions and locking. The file system is regional: data is stored redundantly across multiple Availability Zones, and instances in any of those zones can mount it. EFS supports Linux clients only, so Windows servers need Amazon FSx for Windows File Server instead.
| Need | EBS | EFS |
|---|---|---|
| Attach to many instances at once | Only with Multi-Attach on specific volume types | Yes, by design |
| Capacity | You provision a size | Elastic, no provisioning |
| Availability Zone | One zone | Multiple zones (Regional) |
| Latency | Lowest, block device | Higher, network file system |
| Typical use | Boot disk, database | Shared content, uploads, home directories |
You can use the console, but the CLI shows each moving part.
Create one mount target per Availability Zone you use, each in a subnet of that zone. A mount target is an elastic network interface with an IP address inside your VPC. Instances reach EFS through it, so traffic stays on the private network.
EFS Standard holds frequently used data. Infrequent Access and Archive classes cost less per GB for rarely read files, and a lifecycle policy moves files to them automatically after a period without access. EFS One Zone keeps data in a single Availability Zone at lower cost, which suits development or data you can recreate.
NFS uses TCP port 2049. Make a security group for the mount targets that allows inbound 2049 only from the security group of your instances, not from the whole internet.
If the mount command hangs and then times out, the cause is nearly always this rule, a missing mount target in the instance's zone, or a subnet without a route to the mount target.
The recommended client is the EFS mount helper from amazon-efs-utils. On Amazon Linux 2023:
The tls option encrypts data in transit through a local stunnel proxy, hence the 127.0.0.1 address. The huge size is a placeholder because the file system has no fixed capacity.
Without the helper you can use a plain NFS mount with the recommended options:
Add a line to /etc/fstab so the mount survives a reboot. The _netdev option makes the system wait for networking first.
Test it with sudo umount /mnt/efs && sudo mount -a. A bad fstab line can stop a boot, so add nofail on instances that must still come up if EFS is unreachable.
A new file system is owned by root. Create a directory for your application and set ownership, or use an access point: a named entry point that forces a POSIX user and group and a root directory for every client that connects through it. Access points let several applications share one file system without seeing each other's data. You can also turn on IAM authorization with the iam mount option and a file system policy, so access is controlled by the instance role as well as by network rules.
No. EFS supports NFS clients on Linux. For Windows file shares use Amazon FSx for Windows File Server.
No. Capacity grows and shrinks as you add and remove files, and you pay for the stored data and any provisioned throughput.
Yes, over AWS Direct Connect or a VPN into the VPC, using the mount target IP address. Plan for higher latency than inside the VPC.
No. EBS has lower latency for a single instance. EFS trades some latency for shared access and automatic scaling.
Amazon EFS is a regional, elastic NFS file system for Linux. Create the file system, add a mount target per Availability Zone, allow port 2049 from your instances' security group, install amazon-efs-utils and mount with mount -t efs -o tls. Persist the mount in /etc/fstab, use access points and IAM for tighter control, and choose Elastic throughput and lifecycle policies to manage performance and cost.