DEV Community

sourav
sourav

Posted on

EFS for Centralized Shared Storage

Amazon Elastic File System (EFS) is a highly scalable, fully managed, and centralized shared file storage solution for ec2 instances in AWS.
we will demonstrate how to create and mount an EFS file system to provide centralized storage for multiple users and servers.

  • Creating an EFS File System: I’m creating the EFS using the console. Start by giving a name to your EFS. We will use the custom option to view and configure each setting in detail.

Image description

  • Set the File System Type:
    We have two options: Regional: Provides EFS availability across all availability zones within a region. For best practices and high data availability in production, Regional is recommended.
    One Zone: Stores data in a single availability zone (AZ). This is ideal for testing but may result in data loss if an outage occurs in that AZ.
    We are using default which is Regional.
    Image description

  • Enable Automatic Backups:

Image description

  • Lifecycle Management:
    Reduce costs by configuring lifecycle policies based on data accessibility.
    Standard, Infrequent Access (IA), and Archive storage classes.
    Data can be transits from one storage class to another based on the given time period.
    Once archived, data can transition back to Standard based on accessibility.
    Image description

  • Encryption:
    EFS supports two types of encryption: encryption for the file system and encryption of data in transit. Encryption of data at rest can be enabled during the creation of the EFS file system. However, once the file system is created, its encryption settings cannot be changed. If you need to make an unencrypted EFS encrypted, you will have to create a new encrypted EFS file system.
    You can either choose an existing encryption key or automatically use the default encryption key.

Image description

  • Performance Settings: We can configure performance settings such as throughput limit and I/O. Throughput can be provisioned based on our requirements, and it will also impact the cost of EFS. In this case, I am using the default settings.

Image description

  • Network Access: In the Network Access settings, we can specify the VPC and define the mount target from which we will access the EFS file system. If needed, we can set the IP address for each mount point, or it will automatically assign IPs from the subnet we have specified. Additionally, we can configure security groups for each mount target according to our requirements. In this case, I am specifying the IP for one subnet for clarity.

Image description
In the file system policy, we can set specific policies for the EFS file system. I am keeping the default settings and proceeding with the creation. Now, the EFS file system has been created.

Image description
As shown in the image, the IP address we defined is assigned to the particular subnet. Now, we will proceed with mounting the EFS file system on our server.

  • Mount Steps: We have created a server where we will mount the EFS. For this, I am using Amazon Linux. First, we need to install the amazon-efs-utils package using the following yum command:
yum install amazon-efs-utils
Enter fullscreen mode Exit fullscreen mode

Image description
Now, we need to allow traffic from the server in the EFS file system's security group. We must enable the NFS protocol for the server's IP address or security group.

Image description
Now, let's mount the EFS on our server.
First, we need to create a directory to mount the file system. Then, we will mount the EFS using the file system ID. In our case, the file system ID is fs-063aad737d572ecf3.

We will use the following command:

sudo mount -t efs fs-063aad737d572ecf3 efs
Enter fullscreen mode Exit fullscreen mode

Image description
We can also mount the efs using dns name for the efs file system.

sudo mount -t efs fs-063aad737d572ecf3.efs.ap-south-1.amazonaws.com efs
Enter fullscreen mode Exit fullscreen mode

Image description

We can also use the IP for that particular subnet in the mount target.

sudo mount -t efs -o tls,mounttargetip=172.31.32.10 fs-063aad737d572ecf3 efs
Enter fullscreen mode Exit fullscreen mode

Image description
Conclusion
With these steps, you can create and mount an EFS file system to centralize storage for multiple users and servers. EFS simplifies file management by providing scalable and secure storage with minimal operational overhead.

Top comments (0)