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.

Prerequisites to mount EFS

  • Create two EC2 instances that are running in different AZs.
    Create two Ec2
  • Create a security group that has inbound rules set for SSH, HTTP and NFS.
    Create a security
  • EC2 instances and EFS should have the same security group assigned.
    Ec2 instance

How to mount EFS on EC2 instances

  • Make sure that you've created an Amazon Linux or Amazon Linux 2 EC2 instance.
    Mount EFS
  • Access the terminal for your instance through Secure Shell (SSH), and log in with the appropriate user name.Appropriate user name
  • 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.
    Run the commands

Conclusion

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


Similar Articles