What Is EFS And How To Mount EFS On AWS EC2 Instances

Introduction 

 
Amazon Elastic File System (Amazon EFS) provides a simple, scalable, fully managed elastic NFS file system for use with AWS Cloud services and on-premises resources.
 
Amazon EFS supports the Network File System version 4 (NFSv4.1 and NFSv4.0) protocol, so the applications and tools that you use today work seamlessly with Amazon EFS. Multiple Amazon EC2 instances can access an Amazon EFS file system at the same time, providing a common data source for workloads and applications running on more than one instance or server.
 
Amazon EFS is designed to be highly available and durable for thousands of EC2 instances that are connected to the service. Amazon EFS stores each file system object in multiple availability zones.
 

Prerequistes to mount EFS

  • Create two EC2 instances that are running in different AZs.
What Is EFS And How To Mount EFS On AWS EC2 Instances 
  • Create a security group that has inbound rules set for SSH, HTTP and NFS.
What Is EFS And How To Mount EFS On AWS EC2 Instances 
  • EC2 instances and EFS should have same security group assigned.
What Is EFS And How To Mount EFS On AWS EC2 Instances 
 

How to mount EFS on EC2 instances

  • Make sure that you've created an Amazon Linux or Amazon Linux 2 EC2 instance.
What Is EFS And How To Mount EFS On AWS EC2 Instances 
  • Access the terminal for your instance through Secure Shell (SSH), and log in with the appropriate user name.
What Is EFS And How To Mount EFS On AWS EC2 Instances 
  • Run the following command to switch user root.

    sudo su root
  • Run the following command to install EFS helper on both the EC2 instance.

    sudo yum install -y amazon-efs-utils

  • Run the following command to make directory /efs

    mkdir/efs
  • Run the following command to mount efs on both EC2 instances.

    sudo mount -t efs -o tls fs-20532158:/ /efs
    where fs-20532158 is ID of EFS

  • Run cd/efs 
  • Run the following command to create blank files from the first EC2 instance on EFS.

    touch file{1...5}

  • Run the following commands on the second EC2 instance to check the files which were created from the f‏irst EC2 instance on EFS

    cd /efs
    ls

  • Create one more file 9 on EFS from a second EC2 instance.
  • Run the command ls to check that file file9 from the first EC2 instance on EFS.
What Is EFS And How To Mount EFS On AWS EC2 Instances
 

Conclusion

 
From this article, we learned about the EFS and how to mount EFS on AWS EC2 instances in different availability zones.


Similar Articles