A Network File System is a distributed file system protocol that supports remote hosts to mount file systems through the network and interact with the file systems as though they are mounted sectionally. This allows us to connect resources to centralized servers on the network.
Amazon EFS-Elastic File System gives you a simple, scalable, and fully managed elastic NFS file system to use with AWS Cloud services and on-premises resources.
In this demonstration, we will show you how to configure a Network File System-NFS using AWS EFS and connect to an EC2 instance.
1. Create a File System
From the AWS EFS console, we can easily create a highly available and scalable network file system.
- Login to your AWS management console and search for Elastic File System.
- In the Elastic File System console, click on the button “Create file system.”
- Provide a name to your file system and select the VPC where you want EC2 instances to connect to your file system.
- Review the settings and click on the create button.
2. Deploy an EC2 instance
In this step, we will deploy and configure an AWS EC2 instance to mount and access the file system.
- Login to your AWS management console and search for EC2.
- On the EC2 dashboard, click on Launch Instance to install and configure a virtual machine.
- Provide an instance name and choose the OS image, key pair, instance type, etc.
- Now review the configuration, storage, tagging, and security settings that have been selected for your instance.
- And click on the Launch button at the bottom of the page.
3. Configure the security group
Attach the VPC default security group to the EC2 instance to give EC2 instance network access to the file system.
4. Mount the file system on the EC2 instance
To access the file system created, we need to mount the file system using the Linux mount command and the file system DNS name.
- Login to the AWS Management Console.
- Go to the Elastic File System dashboard and click on the file system name you created.
- Now click on the Attach button on the right top corner
- Copy the DNS command from the dashboard to mount Amazon EFS file system to the EC2 instance.
You can also use the Mount via IP option.
- Now login to the EC2 instance using SSH
- Create a directory for the mount point
# mkdir efs
- And execute the DNS command copied from the dashboard to mount the EFS file system to your EC2 instance.
- Here you can see the EFS file system is mounted to the directory /root/efs by executing the df -h command.
By using this method we have successfully configured Network File Share in the AWS cloud. Elastic File System in AWS acts as a centralized storage for all applications running in the AWS EC2 instances.