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

Mounting NFS on AWS EC2 Instances

SUBAIR NURUDEEN ADEWALE | LinkedIn

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:

  1. An EFS file system

  2. Two EC2 instances

  3. 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

  1. Navigate to EFS Console

  2. Click Create file system

  3. Name your file system and select customize

  4. 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):

  1. Go to EC2 DashboardLaunch Instance

  2. 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)

  3. Click Launch Instance

Need detailed EC2 setup instructions? Follow my EC2 creation guide here.

Step 3: Configure Security Groups

  1. Navigate to Security Groups

  2. 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

  1. 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.

  2. 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

LinkedIn

✉️ nuddywale@gmail.com | 🌐 Nucloud Blog

1
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.