EFS offers two methods to connect your Linux-based EC2 instance to your EFS file system. Both use a process called mounting whereby you mount a target to the EFS file system on your instance. The original method available with EFS used the standard Linux NFS client to perform the mount. Since then, a new method has been developed, and this newer method is now the preferred option, and this uses the EFS mount helper.
The EFS mount helper is a utility that has to be installed on your EC2 instance. This utility has been designed to simplify the entire mount process by using predefined recommended mounting options that are commonly used within the NFS client. It also provides built-in login capabilities to help with any troubleshooting that might be required and are stored in the following location:
/var/log/amazon/efs
In addition to mounting an EFS file system to running instances, you can also use the EFS mount helper to automatically connect to EFS during the boot process, as well as by editing the /etc/fstab configuration file. Before using the EFS mount helper to connect to your EFS file system from your EC2 instances, there are a couple of prerequisites required to be in place. First and foremost, you need to ensure that you have created and configured your EFS file system, in addition to your EFS mount targets. You must have an EC2 instance running with the EFS mount helper installed, and this instance will be used to connect to the EFS file system.
The instance must also be in the VPC and configured to use the Amazon DNS servers with DNS hostnames enabled. You must have a security group configured allowing the NFS file system NFS access to your Linux instance, and you must also be able to connect to your Linux instance. I now want to provide a quick demonstration on how to create an EFS file system from within the AWS Management Console.
Set up
Navigate to EC2 and go to security group.
Create a security group and select the VPC and add the inbound rule of NFS, As NFS will need to be accessed by EC2 instances.
Configuring Security group
Now let’s search for EFS in AWS console, Select Create Elastic File System.
There are 3 steps to be followed here:
Select the VPC to which the EFS should be associated.
Select the mount targets which are in each AZ and select public subnet and security group which we created in before step.
Add tags , life cycle management to move from standard to Infrequent, through put mode, Performance mode, enable encryption. These all options are pre defined and optional. Can be changed as per your requirement.
Once created we can see the DNS Name of the file system access when you open EFS you created in detail.
Now let’s Mound the EFS created to EC2 instances.
This information is also available in your EFS screen and select how to configure
Now ssh to your 2 instances and you do the bash command as shown in the screen
This command installs efs on EC2: sudo yum install -y amazon-efs-utils.
This command creates the directory in EC2 instances: sudo mk dir efs.
This command can be used to mount the EFS to EC2: sudo mount -t efs fs-obc672co.
Top comments (0)