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.
- 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.
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/)
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 .
Step 6 : Once installed , create one directory e.g. efs
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.
Step 10 : Now unmount the directory . In next steps we are going to mount it to another directory.
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.
— Dushyant Mehta
Share with your network.