Setup AWS EFS in easy steps

Spread the love


Hi,

In this post of devOpsJourney , you will see how to Setup AWS EFS in easy steps and start using it.

Before setting up let’s understand what is AWS EFS and its benefits over traditional network file system.

Amazon EFS (Amazon Elastic File System) provides simple and scalable file storage for use with Amazon EC2 instances in the AWS Cloud.

Features :

  • Simple – Easy to setup
  • Scalable – Scale up or down in terms of infrastructure
  • Elastic – grow and shrink automatically as you add and remove files
  • Managed – Managed by AWS
  • Less Complex – deploying, patching, and maintaining complex file system deployments by AWS

At the time of writing it supports Network File System version 4.1 (NFSv4.1) protocol.

At a same time one or more than one Amazon EC2 instances can access an Amazon EFS file system. Useful for a scenario where more than one instance needs access to common data source for an application.

Now let’s see how we can setup EFS step by step.

Step 1 : Sign in to AWS console and click on EFS . Click on create file system.

1_efs_home

 

Step 2 : Select VPC in which you want to create the EFS and select AZs.

 

Step 3 : Enter the tag name and select the performance mode. For better performance (high data transfer rate between EC2 instance and EFS ) choose Max I/O (additional charges may apply . Check https://aws.amazon.com/efs/pricing/)
3_efs_configure

 

Step 4 : Review your configuration and create the EFS.

 

Note down the File system Id which is required to mount the directory of EC2 instance.

Step 5 :  Now Provision one EC2 instance and install the nfs-utils .
5_install_nfs

 

Step 6 : Once installed , create one directory e.g. efs
6_create_dir

 

Step 7 : Mount the directory to EFS we have created in previous steps. Use below command

sudo mount -t nfs4 -o vers=4.1 $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone).file-system-ID.efs.aws-region.amazonaws.com:/ efs

Replace the file-system-ID and aws-region with the values you have. file-system-ID is the id you got after step 4. aws-region is region in which you are launching EFS.

 

Step 8 : Check the mount point .

 

Step 9 : Now we will create a directory a file in order to test EFS. Change the directory to efs. Create one more directory inside it and then create a file inside the directory you just created. List it to check it.
9_test

 

Step 10 : Now unmount the directory . In next steps we are going to mount it to another directory.
10_umount

 

Step 11 : Create one more directory (you can try it in another EC2 instance as well). Mount it to previous EFS and verify the directory and file we created in previous steps.

Yes !! We have it.

 

This was all about our post. Let us know if you have any questions, suggestions, feedback. We ‘ll surely look into this.

Thanks.

— Dushyant Mehta
Share with your network.

3 comments

  1. Good write up again!

    Would be good if you add one point here , mount target IP address /mount target security group should be configured in your instance’s security group. ( If you keep security group wide then these are not at all in question!)
    To me, the best would be to keep a security group dedicated for mount target IP addresses and make entry in instance’s security group/groups whoever needs EFS!

    1. Thanks Biswajit.

      Yes, Agreed ! .

      But here Inbound security group is required. Client IP address need to pass in inbound security groups which has been taken care in step 2.

      Thanks,
      Ishant

Leave a Reply

Your email address will not be published. Required fields are marked *