Amazon Elastic File System
User Guide

Mounting Automatically

You can use the file fstab to automatically mount your Amazon EFS file system whenever the Amazon EC2 instance that it's mounted on reboots. You can set up automatic mounting in two ways. You can update the /etc/fstab file in your EC2 instance after you connect to the instance for the first time, or you can configure automatic mounting of your EFS file system when you create your EC2 instance.

Updating an Existing EC2 Instance to Mount Automatically

To automatically remount your Amazon EFS file system directory when the Amazon EC2 instance reboots, you can use the file fstab. The file fstab contains information about file systems, and the command mount -a, which runs during instance startup, mounts the file systems listed in the fstab file.


Before you can update the /etc/fstab file of your EC2 instance, make sure that you've already created your Amazon EFS file system and that you're connected to your Amazon EC2 instance. For more information, see Step 2: Create Your Amazon EFS File System in the Amazon EFS Getting Started exercise.

To update the /etc/fstab file in your EC2 instance

  1. Connect to your EC2 instance, and open the /etc/fstab file in an editor.

  2. Add the following line to the /etc/fstab file.

    mount-target-DNS:/ efs-mount-point nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0

    If you want to copy the contents of your /etc/fstab file between EC2 instances in different Availability Zones (AZ), we recommend that you use the file system DNS name. Don't copy the /etc/fstab file between AZs if you're using the mount target DNS name. If you do, then each file system has a unique DNS name for each Availability Zone with a mount target. For more information about DNS names, see Mounting on Amazon EC2 with a DNS Name.

  3. Save the changes to the file.

Your EC2 instance is now configured to mount the EFS file system whenever it restarts.


If your Amazon EC2 instance needs to start regardless of the status of your mounted Amazon EFS file system, add the nofail option to your file system's entry in your etc/fstab file.

The line of code you added to the /etc/fstab file sets the following.

Field Description


The Domain Name Server (DNS) name for the file system that you want to mount. This is the same value used in mount commands to mount the subdirectory of your EFS file system.


The mount point for the EFS file system on your EC2 instance.


The type of file system. For EFS, this type is always nfs4.

mount options

Mount options for the file system. This is a comma-separated list of the following options:

  • nfsvers – Identifies the version of NFS to be used. We recommend 4.1 as the value for this option.

  • rsize – Defines the size of the chunks for reading data between your client and the file system in the cloud. We recommend 1048576 as the value for this option.

  • wsize – Defines the size of the chunks for writing data between your client and the file system in the cloud. We recommend 1048576 as the value for this option.

  • hard – Specifies that the local applications using a file on the file system should stop and wait for the file system to come back online if Amazon EFS is temporarily unavailable.

  • timeo – Specifies the amount of time, in tenths of a second, that the NFS client waits for a response before it retries a request to the file system in the cloud. We recommend 600 deciseconds as the value for this option.

  • retrans – Specifies the number of times the NFS client should retry a request. We recommend 2 as the value for this option.

  • _netdev – This is used to prevent the Amazon EC2 instance’s kernel from mounting the file system before the instance has network connectivity.

  • noresvport – With this option, the NFS client uses a new Transmission Control Protocol (TCP) source port when a network connection is re-established. Using a new port helps ensure uninterrupted availability after a network recovery event.

For more information, see Additional Mounting Considerations.


A nonzero value indicates that the file system should be backed up by dump. For EFS, this value should be 0.


The order in which fsck checks file systems at boot. For EFS file systems, this value should be 0 to indicate that fsck should not run at startup.