Amazon Elastic File System

So Amazon Web Services recently released a pretty cool service that has been asked for by many different customers. Traditionally in the EC2 environment, shared storage is some what of a headache. EBS volumes can only be attached to one instance, and S3 buckets are supposed to function more in an object storage role and are not intended to act as a file system. To fix this issue, AWS released the EFS or Elastic File System. With EFS, you can have a shared storage file system that can be mounted and shared between multiple different instances residing in the same AZ.

Setting it up is easy, first you head over to your AWS management console and head over to the EFS page where you then click to create a new file system (please note, this service is currently in preview stage so you have to request access). Once you pick the VPC and AZs you want it to reside in and give it some tags, you are ready to create.

Once the EFS is created, you then need to ready your instances so that the new EFS can be mounted locally within your instance.

  1. Using the Amazon EC2 console, associate your EC2 instance with a VPC security group that enables access to your mount target. For example, if you assigned the “default” security group to your mount target, you should assign the “default” security group to your EC2 instance. (learn more about using VPC security groups with Amazon EFS)
  2. Open an SSH client and connect to your EC2 instance. (find out how to connect)
  3. Install the nfs client on your EC2 instance.
    • On an Amazon Linux, Red Hat Enterprise Linux, or SuSE Linux instance:
      sudo yum install -y nfs-utils
    • On an Ubuntu instance:
      sudo apt-get install nfs-common

Mounting your file system

  1. Open an SSH client and connect to your EC2 instance. (find out how to connect)
  2. Create a new directory on your EC2 instance, such as “efs”.
    • sudo mkdir efs
  3. Mount your file system using the DNS name. The following command looks up your EC2 instance’s Availability Zone (AZ) using the EC2 instance metadata URI, then mounts the file system using the DNS name for that AZ. (what is EC2 instance metadata?)
    • sudo mount -t nfs4 $(curl -s efs

If you are unable to connect, please see our troubleshooting documentation.

Rinse and repeat for every other instance that you want to have a shared filesystem with, and voila, you now have easy and scalable shared storage within EC2.