Mount Elastic File System (EFS) on EC2 Instance (Hands-On)

Search for a command to run...

No comments yet. Be the first to comment.
AWS Agent Plugins let AI coding agents deploy, architect, and operate on AWS. Here's what that means for the future of DevOps.

AWS Storage Gateway bridges your on-premises infrastructure with Amazon's cloud storage — letting you use familiar protocols like NFS, SMB, and iSCSI while your data lives safely in S3, EBS, or Glacie

This AZ-104 domain emphasizes secure identity management and efficient resource governance, which are essential for Azure administrators to ensure compliance and cost control. Overview of Azure Identi

Scaling your EC2 instances to match dynamic workloads can be challenging. Amazon EC2 Auto Scaling simplifies this with target tracking scaling policies, a powerful feature that automatically adjusts capacity to maintain optimal performance and cost e...

IntroductionAmazon Elastic Block Store (EBS) is a cornerstone of AWS storage solutions, offering persistent block-level storage for EC2 instances. While EBS volumes are typically attached to a single instance.# EBS Multi-Attach breaks this mold, allo...

CloudCubes by Jinesh
45 posts
Cloud Infrastructure Consultant
Find me here : jineshkumar.bio.link
https://jineshkumar.com
This lab walks you through mounting EFS on EC2 Instances.
Open AWS Console , Search EFS and Create a EFS File Storage

File Storage's Customizable Settings
Here we can fully see & customize ALL EFS Features.
After that, Click "Attach" on EFS File System to see mounting Options: Mount via DNS & Mount via IP (any one would work)
We can Spin up Amazon Linux AMI using "Launch Instance" under EC2 with default settings & SSH into it. How to here.
Note : When configuring Default / New Security Group on EC2, Make sure Port 22 for SSH and Port 2049 for NFS are Open Inbound Connection from EFS. More on that here,
EFS mount helper requires " amazon-efs-utils " package installed on the EC2 instance. Install it by running command,
sudo yum install -y amazon-efs-utils
Optionally,
Install botocore so that you can use Amazon CloudWatch to monitor your file system's mount status.
Upgrade to the latest version of stunnel to enable encryption of data in transit.
Continue,
Mount your file system using the EFS mount helper.
Make a directory "efs" (or any name) that will be the mount point
sudo mkdir efs
Using the EFS mount helper command for each EFS file system that needs to be mounted and we can enable encryption of data in transit. Run mount command,
sudo mount -t efs -o tls file-system-id efs/
Example
sudo mount -t efs -o tls fs-abcd123456789ef0 efs/
And here, I have successfully mounted my EFS File Storage on EC2 Linux Machine. EFS as our mount point.
Alternatively, We could have mounted NFS Storage using IP ,
sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 172.31.13.38:/ efs
Also, Mounting your Amazon EFS file system automatically can be configured by Updating the EC2's " /etc/fstab " file. More on that here,
Open the /etc/fstab file in an editor. Add the following line to the file Note : relace with your ${file_system_id} and ${mount_point} :
echo "${file_system_id}.efs.us-east-1.amazonaws.com:/ ${mount_point} nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,_netdev 0 0"
Additionally, If the EC2 instance and the file system you are mounting are located in different AWS Regions, see
Mounting Amazon EFS file systems from a different AWS Region to edit the region property in the "efs-utils.conf" file.
AWS Doc Reffered : Using EFS mount helper to mount EFS file systems
Hope this step-by-step tutorial help in learning and getting you hands on experience for AWS Service - EFS and EC2.
Thank you for reading and following along with the Blog.
Happy Learning.
Like and Follow for more Azure and AWS Content.
Regards,
Jineshkumar Patel