"What are the basic steps for mounting, unmounting, automounting, and on-premises mounting my EFS file system?"
"What are the basic steps for mounting, unmounting, automounting, and on-premises mounting of my Amazon Elastic File System (Amazon EFS) file system?"
"What are the basic steps for mounting, unmounting, automounting, and on-premises mounting of my Amazon Elastic File System (Amazon EFS) file system?ResolutionTo mount your Amazon EFS file system, you can either install the nfs-utils package or the efs-utils package.Mounting EFS with efs-utils tools1.    Run the following command to install the efs-utils package:Amazon Linux or Amazon Linux 2$ sudo yum install -y amazon-efs-utilsUbuntu and Debian-based distributions$ sudo apt-get -y install ./build/amazon-efs-utils*deb./build-deb.sh$ cd /path/to/efs-utils$ git clone https://github.com/aws/efs-utils$ sudo apt-get -y install git binutils$ sudo apt-get updateOther Linux distributions$ sudo yum -y install git$ sudo yum -y install rpm-build$ git clone https://github.com/aws/efs-utils$ cd /path/efs-utils$ sudo yum -y install make$ sudo yum -y install rpm-build$ sudo make rpm$ sudo yum -y install ./build/amazon-efs-utils*rpm2.    After the efs-utils package is installed, open the EFS console.3.    Select File systems.4.    Select the file system that you want to mount.5.    Select Attach.6.    Copy the command under using the EFS mount helper.7.    Connect to the instance through SSH or AWS Systems Manager Session Manager and run the command you copied in step 6:$ sudo mkdir -p /mnt/efs$ sudo mount -t efs -o tls fs-12345678:/ /mnt/efs$ sudo mount -t efs -o tls,accesspoint=fsap-12345678 fs-01233210 /mnt/efsNote: Edit the preceding commands as required by replacing the file system id, mount point, and so on.Mounting EFS with the NFS client1.    Run the following command to install the nfs-utils package:RHEL and CentOS-based distributions$ sudo yum -y install nfs-utilsUbuntu-based distributions$ sudo apt install nfs-common2.    After installing the nfs-utils package, navigate to the EFS console.3.    Select File systems.4.    Select the file system that you want to mount.5.    Select Attach.6.    Copy the command under using the NFS mount helper.7.    Connect to the instance through SSH or Session Manager and run the command you copied in step 6:$ sudo mkdir -p /mnt/efs$ sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport mount-target-DNS:/   ~/efs-mount-point-or-Run the following command to mount using an IP address:$ sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport mount-target-ip:/  ~/efs-mount-pointNote: Edit the preceding commands as required by replacing the file system id, mount point, DNS, IP address, and so on.Unmounting an EFS file systemRun the following command to unmount the file system:$ umount /mnt/efsIf the mount point is busy, then use the -l parameter with the umount command:$ umount -l /mnt/efsAuto-mounting a file system using /etc/fstabRun the following commands to make an entry in /etc/fstab so that the EFS mount persists on reboot:# vim /etc/fstabUsing efs-utilsfs-xxxxxxxx:/ /mnt/efs efs _netdev,nofail,noresvport,tls,iam 0 0Using the NFS clientModify the parameters in fstab as needed for your configuration.fs-XXXXXXXX.efs.REGION.amazonaws.com:/ /mnt/efs nfs4 defaults,_netdev,nofail 0 0# mount -aFor various mounting options using the mount helper, see Automatically mount EFS using /etc/fstab with EFS mount helper.Note: You can mount your file system using an IP address of a mount target in a different Availability Zone than the client (Amazon Elastic Compute Cloud (Amazon EC2)). When you do this, consider factors such as cross-Availability Zone data transfer charges, and latency.Mounting EFS on instance launch using the launch wizardWhen launching EC2 instances you can use the launch wizard to add user data automatically for mounting of EFS.1.    Open the EC2 console.2.    Select Launch instances.3.    Select an AMI and an instance type, and then select Next: Configure Instance Details.4.    Configure various parameters as per your requirements. Make sure that you select the required VPC and subnet for EFS mounting.5.    On the Configure instance page, under File systems, choose the EFS file system that you want to mount. The path shown next the file system ID is the mount point that the EC2 instance will use. You can change this path, if needed. User data is automatically generated for mounting EFS in the Advanced details section:#cloud-configpackage_update: truepackage_upgrade: trueruncmd:- yum install -y amazon-efs-utils- apt-get -y install amazon-efs-utils- yum install -y nfs-utils- apt-get -y install nfs-common- file_system_id_1=fs-0cae1679a766bcf49- efs_mount_point_1=/mnt/efs/fs1- mkdir -p "${efs_mount_point_1}"- test -f "/sbin/mount.efs" && printf "\n${file_system_id_1}:/ ${efs_mount_point_1} efs tls,_netdev\n" >> /etc/fstab || printf "\n${file_system_id_1}.efs.us-east-1.amazonaws.com:/ ${efs_mount_point_1} nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,_netdev 0 0\n" >> /etc/fstab- test -f "/sbin/mount.efs" && grep -ozP 'client-info]\nsource' '/etc/amazon/efs/efs-utils.conf'; if [[ $? == 1 ]]; then printf "\n[client-info]\nsource=liw\n" >> /etc/amazon/efs/efs-utils.conf; fi;- retryCnt=15; waitTime=30; while true; do mount -a -t efs,nfs4 defaults; if [ $? = 0 ] || [ $retryCnt -lt 1 ]; then echo File system mounted successfully; break; fi; echo File system not available, retrying to mount.; ((retryCnt--)); sleep $waitTime; done;>-or-To mount EFS on a custom AMI or with specific options, add custom user data with the required commands in the Advanced details section. For more information, see Run commands on your Linux instance at launch.RHEL and CentOS-based distributions#!/bin/bashsudo mkdir -p /mnt/efssudo yum -y install nfs-utilsUbuntu-based distributions#!/bin/bashsudo mkdir -p /mnt/efssudo apt install nfs-commonsudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport mount-target-ip:/  /mnt/efs6.    Launch the instance.Mounting EFS on-premisesTo mount EFS on your on-premises servers, there must be connectivity between EFS and the on-premises servers. You can use AWS Direct Connect and VPN to establish this connectivity.After establishing connectivity between the on-premises server and EFS's VPC, run the following commands to install the NFS client and mount EFS:$ sudo yum -y install nfs-utils (Red Hat Linux)$ sudo apt-get -y install nfs-common(Ubuntu)$ mkdir ~/efs$ sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport mount-target-IP:/  ~/efsFor more information, see Mounting on your on-premises Linux client with the EFS mount helper over AWS Direct Connect and VPN.Follow"