site logo
search logo

Channel

Your Details



Contact Us

Blog

How to Mount a File System on Multiple EC2 Instances to Be Used as a Single Disk on Amazon Web Services?

“Amazon internet Services introduced a shared File Systems for its web-based computational services on 2015. Since then, a multitude of users benefited from this service for exchanging files shared across instances with a common file space. Every solution architect must be aware of this service.”

How to Mount a File System on Multiple EC2 Instances to Be Used as a Single Disk on Amazon Web Services?

That’s a good question. Frankly speaking, we sometimes find solutions to our mission, critical problems in day to day use cases which enables us to mount multiple file systems on a single virtual machine or maybe use multiple virtual machines with one single file system.

 

Thankfully the good folks at Amazon Web Services have developed a managed service that allows to mount as a similar file system on multiple instances i.e. virtual machines.

To mount your Amazon EFS file system on your Amazon EC2 instance, it is recommended that one uses the mount helper in the amazon-efs-utils package. The amazon-efs-utils package is an open-source collection of Amazon EFS tools. For more information, see Installing the amazon-efs-utils Package on Amazon Linux.

 

One can mount an Amazon EFS file system on an Amazon EC2 instance using the Amazon EFS mount helper. To use the mount helper, the following are the steps:

 

  • An Amazon EFS file system ID – After you create an Amazon EFS file system, one can get that file system's ID from the console or programmatically through the Amazon EFS API. This ID is in this format: fs-12345678.

  • An Amazon EFS mount target – One can create mount targets in their virtual private cloud (VPC). If one creates their file system in the console, mount targets must be created at the same time. Further information covered in, Creating a Mount Target Using the Amazon EFS console.

  • An Amazon EC2 instance running a supported distribution of Linux – The supported Linux distributions for mounting your file system with the mount helper are Amazon Linux 2, Amazon Linux 2017.09 and newer, Red Hat Enterprise Linux (and derivatives such as CentOS) version 7 and newer, and Ubuntu 16.04 LTS and newer.

 

The Amazon EFS mount helper installed – A mount helper is a tool in amazon-efs-utils. For information on how to install amazon-efs-utils, see Installing the amazon-efs-utils Package on Amazon Linux.


To mount Amazon EFS file system with the mount helper

 

Access the terminal for the instance via the Secure Shell (SSH), and log in with the appropriate user name. Run the subsequent command to mount the file classification system.

 

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

Alternatively, to use encryption of data in transit, mount the file system with the following command.

 

sudo mount -t efs -o tls fs-12345678:/ /mnt/efs 

Optionally one can mount automatically by adding an entry to /etc/fstab file. When mounting automatically using /etc/fstab, must add the _netdev mount option. For a lot of data, see Updating an Existing EC2 Instance to Mount Automatically.

 

Note:

 

Mounting with the mount helper automatically uses the following mount options that are optimized for Amazon EFS:

 



To use the mount command, the following must be true:

 

The connecting EC2 instance should be in a very virtual non-public cloud (VPC) supported the Amazon VPC service. It conjointly should be designed to use the DNS server provided by Amazon. For data concerning the Amazon DNS server, see DHCP Options Sets in the Amazon VPC User Guide. The VPC of the connecting EC2 instance should have DNS hostnames enabled. For info regarding the Amazon DNS server, see DHCP Options Sets in the Amazon VPC User Guide. The VPC of the connecting EC2 instance should have DNS hostnames enabled. For more information, see Viewing DNS Hostnames for Your EC2 Instance in the Amazon VPC User Guide.

 

Note:

 

It is recommended a wait of 90 seconds after creating a mount target before one mounts their file system. This wait lets the DNS records propagate absolutely within the AWS Region wherever the file classification system.

 


Get our hottest stories delivered to your inbox.

Sign up for Scrabbl Newsletters to get personalized updates on top stories and viral hits.