EFS(Elastic File Storage)

0

What is Amazon EFS?

Amazon Elastic File System (EFS) is a fully managed, serverless, elastic file storage service built for use with AWS Cloud and on-premises resources.

Think of EFS as a shared drive in the cloud — where multiple EC2 instances can read and write to the same files at the same time.


Key Features of Amazon EFS

Fully Managed – No need to provision or manage storage servers.
Elastic Storage – Automatically grows and shrinks as files are added or removed.
High Availability – Data is stored across multiple Availability Zones (AZs).
Scalable Performance – Handles thousands of concurrent connections.
Secure – Integrated with IAM, Security Groups, and KMS encryption.
NFS Protocol Support – Works with standard Linux file system commands.


Components of Amazon EFS (Explained Clearly)

EFS is made up of several components that work together to deliver seamless shared storage. Let’s understand each one:

1️⃣ File System

This is the core component — a logical container for your files and directories.

  • You create it in your AWS region.

  • It automatically scales and replicates data across multiple AZs.

  • It supports NFSv4.1 and NFSv4.0 protocols.

🧾 Example:
You create a file system named my-efs, which can be mounted on EC2 instances in multiple AZs.


2️⃣ Mount Targets

A mount target is like a connection point in each Availability Zone that allows your EC2 instance to access the EFS.

  • Each AZ requires its own mount target.

  • Associated with a Subnet and Security Group.

🧾 Example:
If you have EC2 instances in three AZs (A, B, C), you’ll create one mount target in each AZ.


3️⃣ Access Points

Access points simplify permissions management by providing application-specific entry points into the EFS file system.

  • They define a user identity and directory path for each app.

  • Helpful in multi-tenant or shared workloads.

🧾 Example:
You can create one access point /data/team1 for one application and /data/team2 for another — isolating access.


4️⃣ Performance Modes

EFS offers two performance modes to choose from when creating the file system:

  • General Purpose (Default): Ideal for latency-sensitive workloads like web servers.

  • Max I/O: Used for parallel, high-throughput workloads like big data and analytics.

🧾 Example:
Choose General Purpose for CMS hosting (WordPress), and Max I/O for Hadoop clusters.


5️⃣ Throughput Modes

You can choose how throughput scales with your file system:

  • Bursting Throughput: Automatically scales with storage size.

  • Provisioned Throughput: You manually set the throughput independent of size.

🧾 Example:
Use Provisioned Throughput if you need consistent high performance for small datasets.


6️⃣ Storage Classes

EFS supports two storage classes to optimize cost and performance:

  • EFS Standard: For frequently accessed data.

  • EFS Infrequent Access (IA): For rarely accessed data — cheaper but slightly slower.

🧾 Tip:
You can enable EFS Lifecycle Management to automatically move files to the IA tier after a certain number of days.

MT = Mount Target

  • Each EC2 instance mounts the same file system via NFS.

  • All instances see the same files in real-time.

  • Data is replicated across multiple AZs for durability.


💻 Steps to Create and Mount an EFS

Step 1: Create an EFS File System

  1. Go to EFS Console → Click Create file system.

  2. Choose your VPC and Availability Zones.

  3. Select Performance mode and Throughput mode.

  4. Enable Encryption if needed.

  5. Create the file system.


Step 2: Create Mount Targets

  • AWS will automatically create mount targets in each AZ.

  • Ensure the Security Group allows NFS traffic (port 2049).

Mounting and Configuring Amazon EFS (Elastic File System)

Once your Amazon EFS file system is created, you need to set permissions, mount it on EC2 instances, and verify the configuration. Let’s go step by step 👇


🔒 Step 1: Create an “Allow All” EFS File System Policy

When you create a new EFS, by default, it’s locked down. To allow all clients to mount and write to your file system (for testing or learning environments), you can use the following “Allow All” policy.

⚠️ Note: This is for learning or demo purposes. Never use “Allow All” in production. Instead, use restricted IAM and VPC-based access.

✅ Example – “Allow All” EFS Policy

{
"Version": "2012-10-17",
"Id": "AllowAllAccess",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"elasticfilesystem:ClientMount",
"elasticfilesystem:ClientWrite",
"elasticfilesystem:ClientRootAccess"
],
"Resource": "*"
}
]
}

📍 Where to apply:
Go to your EFS console → File system → Network → File system policy → Edit → JSON editor → Paste and Save.


🧰 Step 2: Install NFS Utilities on EC2 Instance

Before mounting, ensure your EC2 instance has NFS utilities installed.

sudo yum install -y nfs-utils

This package enables the instance to communicate using the NFS (Network File System) protocol.


📁 Step 3: Create a Mount Directory

Now, create a directory that will serve as your EFS mount point:

sudo mkdir /mnt/efs

🔗 Step 4: Mount the EFS File System

Use the DNS name of your EFS (available in the console) and mount it as follows:

sudo mount -t nfs4 -o nfsvers=4.1 fs-0d2b1f09f903ca57c.efs.us-east-1.amazonaws.com:/ /mnt/efs

📘 Explanation of options:

  • -t nfs4: Mount type NFS version 4

  • -o nfsvers=4.1: Specify NFS version 4.1 for better performance

  • fs-xxxx.efs.region.amazonaws.com:/: EFS DNS endpoint

  • /mnt/efs: Mount directory on EC2


⚙️ Step 5: Make the Mount Persistent

To ensure the EFS automatically mounts after a reboot, add an entry to the /etc/fstab file:

echo ‘fs-0d2b1f09f903ca57c.efs.us-east-1.amazonaws.com:/ /mnt/efs nfs4 defaults,_netdev 0 0’ | sudo tee -a /etc/fstab

Step Component Purpose
Create Mount Targets One per AZ Allows EFS to connect to EC2 in that AZ
Use DNS Name For mounting Automatically maps to correct mount target

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top