A Step-by-Step Guide to Deploying EC2 Instances with Shared EFS Storage


Mounting NFS on AWS EC2 Instances
Introduction to Amazon EFS
Mounting NFS on AWS EC2 Instances
Amazon Elastic File System (EFS) is a scalable cloud file storage service that works with:
Amazon EC2, ECS, EKS
AWS Lambda and Fargate
On-premises servers
Key Features:
✔ Scales automatically with your files
✔ Supports thousands of concurrent EC2 instances
✔ Offers multiple file system types and performance modes
✔ Provides NFSv4 protocol support
✔ Includes encryption at rest and in transit
Project Scenario
Your company needs to deploy two EC2 instances that require real-time file sharing. We'll configure:
An EFS file system
Two EC2 instances
Proper security groups
Prerequisites
AWS account with appropriate permissions
Basic AWS EC2/EFS knowledge
AWS Management Console access
Step 1: Create an EFS File System
Navigate to EFS Console
Click Create file system
Name your file system and select customize
Select Customize and configure:
File System Settings:
Keep default settings
Click Next
Network Access:
Use default VPC and subnets
Click Next
File System Policy:
Enable Enforce in-transit encryption
Click Next → Create
Step 2: Deploy two EC2 Instances
For each instance (repeat steps):
Go to EC2 Dashboard → Launch Instance
Configure:
Name: Efs-server1 and Efs-server2
OS: Amazon Linux
Instance type: t3.micro
Key pair: "Proceed without key pair"
Security group: Create new (e.g., Efs-1, Efs-2)
Click Launch Instance
Need detailed EC2 setup instructions? Follow my EC2 creation guide here.
Step 3: Configure Security Groups
Navigate to Security Groups
Edit inbound rules for each instance's group:
Click on the security group default id and Click on Edit inbound rules
Add rule: NFS (2049)
Source: Select the other instance's security group (Efs-1 and Efs-2)
Save rules
Step 4: Mount EFS to EC2 Instances
For each instance:
A. Connect via Cloud Shell
Select instance → Connect → **EC2 Instance Connect (Need detailed EC2 setup instructions and how to connect using EC2 instance Connect? Follow my EC2 creation guide here.
Navigate to EFS, Click on EFS (subbyEfs) and also Click on attach to view EFS mount helper command
B. Run Mount Commands on both EC2 instance
# Install EFS utilities sudo dnf install -y amazon-efs-utils
# Create mount directory sudo mkdir efs
# Mount EFS (use your EFS mount helper command) sudo mount -t efs -o tls fs-0009671413ec18b07:/ efs
# Set permissions sudo chown ec2-user efs/
# Verify df -T
# Open the directory by running Cd Efs
Run ls -l to list the content of the efs directory…the efs directory is empty.
# Test file creation by using sudo touch oba.html subby.html subby.css to create the following files on one of the instance.
Verification
Files created on one instance should appear on the other
Conclusion
You've now set up:
Highly available shared storage
Encrypted file transfers
Cross-instance file synchronization
Join My Cloud Journey!
Subscribe for more AWS/Azure guides and cloud engineering tips.
Connect With Me
✉️ nuddywale@gmail.com | 🌐 Nucloud Blog
Subscribe to my newsletter
Read articles from SUBAIR NURUDEEN ADEWALE directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

SUBAIR NURUDEEN ADEWALE
SUBAIR NURUDEEN ADEWALE
Hello! I'm Subair Nurudeen Adewale, a cloud computing enthusiast and the founder of Nucloud Blog. I'm passionate about sharing knowledge and insights on cloud infrastructure, security, innovation, and the intersection of technology and design. As a cloud expert with a keen eye for user experience, I explore the latest trends and best practices in UI/UX, and how they can be applied to create intuitive, user-friendly, and seamless experiences for cloud-based applications and services. Follow Nucloud Blog for the latest updates and insights from the world of cloud computing and UI/UX design.