How to mount AWS EFS on AWS ec2

How to mount AWS EFS on AWS EC2

In this post i will be discussing on ‘How to mount AWS EFS on AWS ec2’  is on how to setup an AWS EFS file system and most importantly how this can be accessed(mounted) by 2 EC2 instances simultaneously.

If you want to know to How to launch an EC2 instance, please click ‘How to Launch my first EC2 Instance‘. It is must to have at least 2 EC2 instances either before or after creating EFS, to test it out.

You  click here for EFS service description and usage.

You can click here for EC2 service description and usage.

For all other important AWS Service click here.

Create EFS Service

I will be explaing here on how to launch a AWS EFS service,

  1. EFS is available under Storage Services.
AWS EFS Mount on EC2 Instance

AWS EFS Mount on EC2 Instance

2. Click on Create file system, which will take us to configure file system. Select your VPC, AZ (which AZ’s this can be mounted on,by default all will be checked) and Security Group and then click next.

Create file system

3. If you want to Add tags for your reference, select performance mode – default ‘General Purpose’ , select throughput – default Bursting, Enable Encryption – default unchecked and then click on next.

Configure EFS




4. Review & create the EFS.

Review

5. It will take a couple minute  to create the EFS. You will see ip address, which will be used to mount from EC2 instance.

Creation inprogress


EFS Created

6. Now go to your EC2 if already created, else launch a new EC2 instance follow the below,

  •  Launch your first EC2 Instance.
  • Go to mount point directory.
    • cd /mnt
  • Create a directory where this EFS will need to be mounted.
    • mkdir dummyefs
  • Now use the below command to mount your EFS, note: you will have to replace the ip as per your EFS ip which was created earlier.
    • mount -t nfs4 172.31.7.160:/ /mnt/dummyefs
  • Issue df -h command to see yourself the mounted directory.
  • Create a file and save it, so the same can be accessed from another EC2 instance.

Putty Setup

7. Launch your second EC2 instance to get access to the above created file from the EFS mounted point.

  • Again create a Directory.
  • Mount the EFS file system using the mount command.
    • mount -t nfs4 172.31.7.160:/ /mnt/dummyefs
    • Confirm the mount by issuing df -h command.
    • Go to the mount directory and cat for the file which was created by your First EC2 instance.

EFS Mount on EC2

That’s it! you have successfully created AWS EFS mounting on AWS EC2 instances.

You may also like...