AWS LAB

Mount Elastic File System (EFS) on EC2

Lab Details:

  1. This lab walks you through the steps to create an Elastic File System.
  2. You will launch and configure two Amazon EC2 Instances.
  3. You will practice mounting the EFS to both instances by logging into each instance via SSH authentication.
  4. You will practice sharing files between two instances.
  5. Duration: 1 hours
  6. AWS Region: US East (N. Virginia)

Lab Tasks:

  1. Log into AWS Management Console.
  2. Create an Elastic File System.
  3. Create 2 Amazon Linux Instances from an Amazon Linux AMI
  4. Find your instance in the AWS Management Console.
  5. SSH into your instance.
  6. Install NFS Client and mount EFS onto the instances.
  7. Test sharing files between the instances.

Architecture Diagram:


Steps

Launching two EC2 Instances

  • Make sure you are in the N.Virginia Region.
  • Navigate to the  menu at the top and click on  in the  section.
  • Select Instances from the left menu and then click on 
  • Search and Choose Amazon Linux 2 AMI:
  • Choose an Instance Type: Select  and then click on the 
  • Configure Instance Details:
    • Number of Instances :  Enter 2
    • No need to change any other settings. Click on 
  • Add Storage: No need to change anything in this step. Click on 
  • Add Tags: Click on 
    • Key    : Enter Name
    • Value    : Enter MyEFS
    • Click on 
  • Configure Security Group:
    • Security Group Name: Enter EFS-SG
    • To add SSH:
      • Choose Type: 
      • Source:  (Allow specific IP address) or  (0.0.0.0/0).
    • For NFS:
      • Click on 
      • Choose Type: NFS
      • Source:  (Allow specific IP address) or  (0.0.0.0/0).
    • After that, click on 
  • Review and Launch : Review all settings and click on 
  • Key Pair : Create a new key pair and click on  . After that, click on 
  • Launch Status: Your instance is now launching. Click on the instance ID and wait until the initialization status changes to 
  • Click on each instance and enter a names as MyEC2-1 and MyEC2-2.


  1. Take note of the IPv4 Public IP Addresses of the EC2 instances and save them for later.

Creating an Elastic FIle System

  1. Navigate to EFS by clicking on the  menu at the top. Click on EFS in the   section.
  2. Click on Create File System.


  3. Configure Network Access:
  • VPC
    • An Amazon EFS file system is accessed by EC2 instances running inside one of your VPCs.
    • Choose the same VPC you selected while launching the EC2 instance (leave as default).
  • Mount Targets
    • Instances connect to a file system by using a network interface called a mount target. Each mount target has an IP address, which we assign automatically or you can specify.
    • We will select all the Availability Zones (AZ’s) so that the EC2 instances across your VPC can access the file system.
    • Select all the Availability Zones, and in the Security Groups, select EFS-SG instead of the default value.
    • Click on 


  • Configure File System Settings
    • Add tags:
      • Key    : Enter Name
      • Value : Enter MyFirstEFS
    • Enable Lifecycle Management :  Choose None
    • Choose Throughout mode   : Choose Bursting
    • Choose Performance mode:  Choose General Purpose
    • Enable Encryption  : Leave it as default
    • Click on 
  • Configure Client Access: No need to change anything. Click on 
  • Review and Create: Review the configuration below before proceeding to create your file system.
  • Click on 


  1. Scroll down on the page. You can see the Mount target status is set to Creating. Wait for the status to be Available.
  2. Open the EC2 dashboard in a seperate tab.

What to do if your Putty session times out:

  • Note: Putty doesn’t work or becomes inactive if it is left idle for sometime. If you get stuck in putty and cannot type, we can duplicate the session.
  • Right click on top, click on Duplicate Session, and close the current session with yes to the warning.


Mount the File System the MyEFS-1 Instance

  1. Select the MyEFS-1 Instance and copy the IPv4 Public IP.
  2. SSH into the EC2 Instance
  • Please follow the steps in SSH into EC2 Instance.
    • Switch to root user
      •  sudo -s
    • Run the updates using the following command:
      • yum -y update
    • Install the NFS client.
      • yum -y install nfs-utils
    • Create a directory by the name efs
      • mkdir efs
    • Mount the file system in this directory. To do so, navigate to EFS and copy the DNS Name in the file system.


  • mount -t nfs dns-name:/ efs/
  • Note: Enter your EFS DNS Name in the place of dns-name above.
    • To display information for all currently-mounted file systems, we’ll use the command bellow:
      • df -h


    • Create a directory in our current location:
      • mkdir aws


Mount the File System to MyEFS-2 Instance

  1. Select the MyEFS-2 Instance and copy the IPv4 Public IP.
  2. SSH into the EC2 Instance
  • Please follow the steps in SSH into EC2 Instance.
  • Switch to root user
    •  sudo -s
  • Run the updates using the following command:
    • yum -y update
  • Install the NFS client.
    • yum -y install nfs-utils
  • Create a directory with the name efs
    • mkdir efs
  • Mount the file system in this directory. To do so, navigate to EFS and copy the DNS Name in the file system.


  • mount -t nfs dns-name:/ efs/
  • Note: Enter your EFS DNS Name in the place of dns-name above.
  1. To display information for all currently mounted file systems, we’ll use the command
  • df -h


Testing the File System

  • SSH into both instances in a side-by-side view on your machine, if possible.
  • Switch to root user
    •  sudo -s
  • Navigate to efs directory in both the servers using command
    • cd efs
  • Create a file in any one server.
    • touch hello.txt
  • Check the file using command
    • ls -ltr
  • Now go to the other server and give command
    • ls -ltr
  • You can see the file created on this server as well. This proves that our EFS is working.
  • You can try creating files (touch command) or directories (mkdir command) on other servers to continue to grow the EFS implementation.


Completion and Conclusion

  1. You have successfully created an Elastic File System.
  2. You have successfully created 2 Amazon Linux instances.
  3. You have successfully installed the NFS Client and mounted EFS to the instances.
  4. You have successfully tested the file-share between both Instances.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: