Amazon Elastic File System (EFS) is an AWS file storage service that allows the same file system to be mounted across multiple servers. It provides shared storage without requiring administrators to manage storage separately on each instance.

Introduction

EFS can be used in scenarios where multiple servers need access to the same files and directories. Similar to NFS, an EFS file system can be mounted on multiple instances within the same AWS Region.

Prerequisites

  • AWS account with permission to create EFS resources
  • EC2 instance running Ubuntu or CentOS
  • Access to the AWS Management Console
  • VPC with appropriate Availability Zones
  • Security group configured to allow NFS traffic
  • Root or sudo access to the instance

Limitations

  • EFS is available only in supported AWS Regions.
  • An EFS file system can be mounted within its AWS Region and cannot be directly mounted from another Region.

Implementation

Step 1: Create an EFS File System

Log in to the AWS Management Console.

Navigate to EFS and select Create File System.

Step 2: Configure the EFS File System

Select the required VPC.

Under Create mount targets, select the required Availability Zones and Security Groups.

Step 3: Select the Performance Mode

Provide a name for the EFS file system.

Select General Purpose as the performance mode.

After creating the file system, AWS provides a DNS name for the EFS file system.

Step 4: Install the NFS Utility

The EFS file system can be mounted on Linux servers using NFS.

For Ubuntu, install nfs-common:

apt-get install nfs-common

For CentOS, install nfs-utils:

yum install -y nfs-utils

Step 5: Create the Mount Directory

Create a directory or use an existing directory as the EFS mount point.

For example:

mkdir -p /var/www/html

Step 6: Mount the EFS File System

Use the EFS DNS name to mount the file system.

mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 EFS-DNSNAME:/ /var/www/html

Replace EFS-DNSNAME with the DNS name of the EFS file system.

Step 7: Configure Permanent Mounting

To automatically mount the EFS file system after a server reboot, edit /etc/fstab.

vi /etc/fstab

Add the following entry:

EFS-DNSNAME:/ /var/www/html nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0

Replace EFS-DNSNAME with the EFS endpoint.

Step 8: Verify the Mount

After mounting the EFS file system, verify that it is mounted successfully.

df -h

The EFS file system should appear with /var/www/html as the mount point.

Conclusion

AWS EFS provides shared file storage that can be mounted across multiple Linux servers within the same AWS Region. By configuring the appropriate NFS utilities, mounting the EFS endpoint, and adding the entry to /etc/fstab, the shared file system can remain available across server reboots.

Related Articles

Leave a Reply