With Amazon EFS(elastic file system)mounted in the EC2, you can signifincalty reudce cost of storge becaues you pay only for the storgrage used by your applications/data. EFS supports NFS
In the AWS console, search for EFS and then create a volume. When you attahce a security group in the EFS, make sure it allows traffc on port 22 from the EC2 instance. Also, take note of the DNS name of EFS, which will be used to mount the volumen in the EC2.
SSH to the Ec2 and create a mount directory.
sudo mkdir efs
Note:if you want you can specify the full path of the mount directory such as /home/efs or /var/efs
Next, take a note of the NFS endpoint DNS name and add the following line in the fstab. Remember to replace the endpoint by yours.
sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport fs-033a1bcb.efs.eu-west-1.amazonaws.com:/ efs
to auto mount the EFS when the EC2 instance restarts, you can add the mount -a in the /etc/fstab. Add the following lines to permanently mount the EFS
fs-033a1bcb.efs.eu-west-1.amazonaws.com:/ /home/centos/efs nfs4 defaults,_netdev 0 0
after adding the mount point the fstab, you need to run:
sudo mount -a
now, if you reboot the instance, the EFS will be auto mounted.
To verify the EFS mount status run the following command:
$ df -T