Skip to content

Mounting an EFS File System

This guide provides step-by-step instructions for mounting an Amazon EFS file system on an Amazon EC2 instance. This will allow your EC2 instance to access the shared file system.

Before you begin, you will need:

  • An active University of Oregon AWS account.
  • An existing EFS file system. You can create one by following our EFS Overview guide.
  • An running EC2 instance in the same VPC as your EFS file system. You can create one by following our Introduction to EC2 guide.
  • The ID of your EFS file system.

First, connect to your EC2 instance using SSH. You will need the public IP address or DNS name of your instance and your private key.

Terminal window
ssh -i /path/to/your-key.pem ec2-user@your-instance-ip

The EFS mount helper is a utility that simplifies mounting and unmounting EFS file systems. It is recommended to use the mount helper to mount your file systems.

To install the EFS mount helper on Amazon Linux 2, use the following command:

Terminal window
sudo yum install -y amazon-efs-utils

For other Linux distributions, please refer to the official AWS documentation.

Step 3: Create a Directory for the Mount Point

Section titled “Step 3: Create a Directory for the Mount Point”

Next, create a directory that you will use as the mount point for your EFS file system.

Terminal window
sudo mkdir /mnt/efs

Now you can mount the EFS file system to the directory you just created. Replace fs-12345678 with the ID of your EFS file system.

Terminal window
sudo mount -t efs fs-12345678:/ /mnt/efs

You can verify that the file system is mounted correctly by running the df -h command.

Terminal window
df -h

You should see your EFS file system listed in the output.

Step 5: Automatically Mount the File System on Boot

Section titled “Step 5: Automatically Mount the File System on Boot”

To ensure that your EFS file system is automatically mounted whenever your EC2 instance reboots, you should add an entry to the /etc/fstab file.

Open the /etc/fstab file in a text editor:

Terminal window
sudo nano /etc/fstab

Add the following line to the end of the file, replacing fs-12345678 with your file system ID:

fs-12345678:/ /mnt/efs efs _netdev,tls 0 0

Save and close the file. Now your EFS file system will be automatically mounted on boot.

  • Mount command fails: Ensure that your EC2 instance’s security group allows outbound NFS traffic (port 2049) to the security group of your EFS mount targets.
  • Connection timed out: Verify that your EC2 instance and EFS mount targets are in the same VPC and that the route tables are configured correctly.

Now that you have mounted your EFS file system, you can start using it to store and share data between your EC2 instances.

  • Learn how to use EFS Access Points to manage application access to your file system.