🚀 From Scratch to Setup: Attaching Amazon EFS to Your EC2 Instance Like a Pro


👋 Hey there! Welcome to my blog — and thank you for stopping by! Whether you’re new here or a regular reader, I truly hope my previous guides have given you valuable insight and a smoother journey through the cloud.
Today, we’re diving into something super exciting and very practical — how to attach an Amazon EFS (Elastic File System) to your EC2 instance.
But first, let’s get something out of the way. If the term “EFS” sounds a bit technical or intimidating, don’t worry. I’ve got you covered. By the end of this guide, you’ll not only understand what EFS is, but you'll also know exactly how to set it up — like a DevOps champ! 💪
📦 So... What Exactly Is Amazon EFS? (And Why Should You Care?)
Imagine a magical shared folder that automatically grows when you need more space, shrinks when you don’t, and lets multiple computers access the same files at the same time — from anywhere.
That’s basically Amazon EFS!
EFS (Elastic File System) is a serverless, fully managed file storage service built for:
Amazon EC2
Containers (ECS, EKS, Fargate)
AWS Lambda
And even on-premise servers
Here’s why it’s awesome:
🔹 Key Features:
✅ Fully managed & scalable – No capacity planning headaches! AWS handles it for you. ✅ Mountable on multiple EC2s at once — Hello, file sharing!
✅ Works with EC2, Lambda, ECS, and even on-prem servers – Super flexible
✅ Multi-AZ durability – Your data stays safe even if an AWS zone has issues.
✅ NFS support (v4.0 & v4.1) – Perfect for Linux-based workloads.
✅ Security-first – Supports encryption at rest & in transit + IAM access control.
💡 Pro Tip: EFS is ideal for shared storage across multiple instances—think web servers, content management systems, or big data workloads! Whether you’re running a high-traffic app or a scalable web server, EFS gives you a simple and secure way to store and access files from multiple compute resources.
🧰 What You’ll Need Before We Begin
To follow along, you’ll need to have the following:
🔹 1. An AWS Account
Don’t have one yet? No stress — just sign up here:
👉 Create an AWS Account
Already signed up? Great! Log in here:
👉 AWS Console Login
💡 Tip: Once your account is created, that main account is the Root user. It's best to create an IAM user for daily tasks to follow best security practices.
🔹 2. Amazon EFS
We’ll create a new EFS file system from the AWS Console and configure it to communicate with your EC2 instances.
🔹 3. EC2 Instances
I’ll be using two EC2 instances to demonstrate how they can both access the same EFS, making it ideal for shared applications or clustered environments.
🔹 4. Security Groups
Think of this as your firewall. We’ll set up Security Group rules to make sure your EC2 instances and EFS can talk to each other securely and without hiccups.
🎯 Ready to Dive In?
Now that we know what EFS is and why it’s such a game-changer, we’ll move on to the fun part — getting everything up and running!
In the next section, we’ll:
Create an EFS file system
Launch and configure EC2 instances
Mount EFS to EC2
Test access from both machines
Grab a cup of coffee (or zobo 🍹), and let’s build something awesome together.
🛠️ Step 1 : Creating Your Amazon EFS File System
Let's get your shared cloud storage up and running!
🔍 Find EFS in AWS Console
Type "EFS" in the search bar at the top
Click on "Elastic File System" from the results
🚀 Create a New File System
- Click the big orange "Create file system" button
🏷️ Name Your File System
Give it a clear, memorable name (e.g., "my-app-shared-storage")
Your VPC will be automatically selected
⚙️ Customize Settings (Pro Tip!)
Click "Customize" to tweak advanced options
For now, you can keep Steps 1 & 2 at default settings
Jump down to Step 3: Network & Security
🔒 Enable Encryption (Recommended!)
Check the box for "Encryption in transit"
Why? This protects your data while it's moving between your instances and EFS
Think of it like a secure tunnel for your files
Also input the Json policy.
🎉 Finalize Creation
Review your settings
Hit that "Create" button!
✅ Boom! Your EFS file system will now be provisioned. Once it’s ready, you’ll be able to mount it from your EC2 instances.
💡 Pro Tip: While we wait for creation to complete, why not grab a coffee? ☕ (or zobo 🍹) This usually takes 1-2 minutes.
🖥️ Step 2: Launching Your EC2 Instances - Let's Build Your Cloud Servers!
Hey there, cloud architect! 🌥️ Ready to create the virtual machines that will power your application? This is where the magic starts! Let's walk through launching your EC2 instances carefully.
🔍 Finding the EC2 Dashboard
Up in the AWS console's search bar (it's like your cloud GPS!), type in "EC2"
When "EC2" pops up in the results, give it a click - this is your gateway to virtual servers!
🚀 Initiating Your Instance Launch
Spot that beautiful orange "Launch Instance" button? That's your start button!
Give it a confident click - you're about to create your first cloud server!
🏷️ Naming Your Instance (Be Creative!)
In the "Name" field, type something memorable like:
"web-server-prod" for production
"dev-test-server" for development
"my-first-ec2" if you're feeling nostalgic!
Pro Tip: Good naming saves hours later when you have dozens of instances!
🖼️ Selecting Your AMI (The Blueprint)
Under "Application and OS Images", you'll see:
Amazon Linux 2023 (recommended for new projects)
Amazon Linux 2 (great for compatibility)
Various other options
Why Amazon Linux? It's optimized for AWS and includes all the tools you'll need!
⚡ Choosing Your Instance Type (The Engine)
For the free tier, you've got excellent options:
t2.micro (1 vCPU, 1GB RAM - perfect for learning)
t3.micro (slightly newer architecture)
Fun Fact: These can handle small websites, APIs, or development environments!
See the "Free tier eligible" badge? That's AWS giving you free compute power to learn!
🔑 Key Pair Setup (Your Secure Access)
If this is your first time, create a new keypair for connecting with SSH agent like Gitbash , if you are connecting through AWS Terminal, you can proceed without the Keypair, though it not recommended.
Click "Create new key pair"
Name it something like "my-ec2-key"
Download the .pem file - this is SUPER important!
Security Note: Store this file securely - it's like the key to your server's front door!
For this training, I proceeded without the keypair
🛡️ Network Settings (Your Virtual Firewall)
AWS automatically creates a security group
For now, allow SSH access (port 22) from your IP
Create separate security groups for each instance
We'll tighten security after we confirm everything works!
💾 Storage Configuration (Your Virtual Hard Drive)
Default is 8GB gp2 root volume - perfect for starters
Need more space? You can increase this up to 30GB in free tier!
🎉 Launch Day!
Take a deep breath - you've got this!
Click that "Launch Instance" button with confidence
See the confirmation screen? You've just created your first cloud server!
✅ Boom! You're now a cloud engineer! Your instance will be ready in about 1-2 minutes.
At this point, the instance is successfully launched.
Follow same steps and create the second instance. After the second instance is successfully launched, this is what you would be having.
💡 Pro Tips for Success:
Create two instances so we can test EFS sharing later!
Name them logically like "Server1_efs" and "Server2-efs"
Check your free tier usage in the Billing Dashboard to stay within limits
The instance state will change from "pending" to "running" when ready
👉 Coming Up Next: We'll connect these shiny new instances to your EFS storage - get ready for some real cloud magic! ✨
Troubleshooting Help:
If anything seems stuck:
Refresh the EC2 dashboard
Check the "Instance State" column
AWS Status page (sometimes rare delays happen)
Remember: Every expert was once a beginner. You're doing great! 😊
🛡️ Step 3: Configuring Security Groups - Building Safe Pathways for Your EFS!
Security Champion Alert! 🔐 Now that your instances are running, let's make sure they can safely talk to your EFS. Think of this like building secure bridges between your servers and storage!
🌉 Setting Up the Communication Pathways
📍 Navigating to Security Groups
In your AWS Console, go to "Network & Security"
Click on "Security Groups" (your virtual bouncers!)
Pro Tip: This is where all your traffic rules live - like a VIP list for your cloud resources
🔍 Identifying Your Security Groups
You'll see three important groups:Default Group: Created automatically with your EFS (this is our main focus) renamed “Efs-Sg”
1st_server-sg: Created with your first EC2 instance
2ns_server-sg: Created with your second EC2 instance
Visual Checkpoint: The "Group Name" column helps identify them easily!
⚙️ Editing the Default Security Group
Select the default security group (associated with your EFS)
Click "Edit inbound rules" (the golden ticket to access control!)
🔧 Configuring the NFS Access Rules
➕ Adding Your First Rule
Click "Add rule" (we're building your first secure bridge!)
For Type: Select "NFS" from the dropdown
- Fun Fact: This automatically sets port 2049 - the special door for EFS communication!
For Source: Choose "Custom" and select “1st_server-sg”
- Translation: "Only allow Instance 1 to talk to this EFS"
🔄 Repeating for Second Instance
Click "Add rule" again
Select "NFS" type once more
This time, choose “2nd_server-sg” as the source
Pro Tip: Double-check you've selected the right SG for each instance!
💾 Saving Your Rules
Click "Save rules" (your changes go live immediately!)
Security Check: AWS will show a quick "success" notification
✅ Verifying Your Setup
Your final inbound rules should look like this:
Type: NFS (port 2049)
Protocol: TCP
Source: 1st_server-sg (for first instance)
Source: 2nd_server-sg (for second instance)
Visual Cue: Two clean NFS rules, each pointing to their respective instance SGs
💡 Expert-Level Pro Tips:
The Principle of Least Privilege: We only opened exactly what's needed (port 2049) - no more, no less!
Future-Proofing: Need to add more instances later? Just add their SGs to these rules!
Troubleshooting: If connections fail, always check:
Are the security groups correctly assigned?
Are the instances in the same VPC as the EFS?
Did you save the rules properly?
👉 Next Up: We'll mount this EFS to your instances and see the magic of shared storage in action! Get ready for some real cloud wizardry! ✨
Encouragement Corner:
You're doing amazing! Configuring security groups is one of the most important (and often tricky) parts of AWS. By getting this right, you're building proper, secure architectures from day one. High five! 🙌
🔗 Step 5: Mount the EFS and Connect EC2 Instances
Here’s where the magic happens — it’s time to hook up our EC2 instances to the shared Amazon EFS and watch them become besties!
💡 Action 1: Connect to Your First EC2 Instance
Head back to your EC2 dashboard and click Connect on one of your instances.
I used EC2 Instance Connect because I didn’t have a key pair set up.
🔐 If you're using a key pair instead, check out my guide: "Quick Guide to Deploying a Linux EC2 Instance on AWS".
Once connected, you’ll be greeted with a terminal window — the heart of the operation!
📦 Action 2a: Install EFS Utilities
We need the EFS helper tools. I'll summon the Amazon EFS tools with a single command!" 🔮:
sudo dnf install -y amazon-efs-utils
Watch in awe as:
✅ Packages appear out of thin air
✅ Dependencies resolve themselves
✅ We get ready for mounting magic!
🔐 Action 2b: Auto-Mount on Reboot (So You Never Lose It!)
# Add to /etc/fstab so it mounts on boot
echo "fs-12345678:/ /mnt/efs efs defaults,_netdev 0 0" | sudo tee -a /etc/fstab
# Test if fstab works (no errors = success!)
sudo mount -a
Boom. That gets you everything needed to talk to EFS.
📁 Action 3: Create a Mount Directory
Creating Our Mount Point "Every good file system needs a landing pad!" 🚀We need a spot on the instance to mount the EFS. I made one called /efs:
sudo mkdir /efs
📎 Action 4: Get the Mount Command
Head back to the EFS page in your AWS Console.
Click Attach.
Copy the command under “Using the EFS mount helper” — AWS even generates it for you!
🚀 Action 5: Mount the EFS
Paste the command in your terminal. It’ll look like this (replace with your file system ID):
sudo mount -t efs -o tls fs-xxxxxxx:/ /efs
🕵️ Action 6: Verify the Mount
Let’s make sure the EFS is really connected:
df -T
You’ll see EFS listed with nfs4
as the type — that means it's mounted and ready!
Check the contents:
ls -l /efs
Oops — don’t have permissions? "The root user hoards all the power! Let's start a revolution!" ✊ Fix it like this:
sudo chown ec2-user /efs
Now YOU own the filesystem! (Democracy in action!)
Now switch to the directory:
cd /efs
📝 Action 7: Create Some Files
Let’s give our EFS something to hold:
touch efs-demo.txt
Want to upload a WordPress zip? Go ahead and drag it into /efs
. Use the command below
To download WordPress on your EC2 instance (or any Linux terminal), use the wget
command to fetch the latest WordPress package:
wget https://wordpress.org/latest.tar.gz
Then extract it:
tar -xvzf latest.tar.gz
Confirm the contents:
ls
Nice! You’ve added files to a storage space shared across instances. Let’s test that sharing next.
🔁 Action 8: 🧪 The Big Test: Instance #2 Joins the Fun!
"Can the second instance see what the first created? Let's find out!" 🔍
Repeat all mounting steps on Instance #2
Connect using EC2 Instance Connect.
Install the EFS tools:
sudo dnf install -y amazon-efs-utils
- Make the same directory:
sudo mkdir /efs
- Mount the EFS:
sudo mount -t efs -o tls fs-xxxxxxx:/ /efs
- Jump into the directory:
cd /efs
- And now for the moment of truth:
ls
🎪 MIRACLE OF MIRACLES!
🎉 Boom! The same files appear! It's like teleportation! ✨ The same files you created on Instance 1 are right here too. That's EFS in action — a fully shared file system that makes teamwork between EC2s seamless.
🎤 Final Bow: Why This Matters
You've just:
✅ Created shared cloud storage
✅ Mounted it without SSH keys
✅ Made servers share files like besties
✅ Become an AWS circus ringleader! 🎪
What's next? How about auto-mounting for an entire fleet of servers? The show must go on! 🚀
Subscribe to my newsletter
Read articles from Funmilola Elizabet Opeyemi Musari directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Funmilola Elizabet Opeyemi Musari
Funmilola Elizabet Opeyemi Musari
I am a Food Technologist & Sales Strategist turned DevOps Explorer | Leveraging problem-solving and client-centric skills to build resilient cloud systems. Currently mastering CI/CD pipelines, Azure, and Infrastructure as Code (Terraform) to automate deployments like a well-oiled production line. Passionate about merging operational efficiency with technical innovation—because great systems, like great recipes, require precision and scalability.