Linux NFS Mount Entry in fstab ( /etc/fstab ) with Example

NFS stands for ‘Network File System’. This mechanism allows unix machines to share files and directories over the network. Using this feature, a Linux machine can mount a remote directory (residing in a NFS server machine) just like a local directory and can access files from it.

A NFS share can be mounted on a machine by adding a line to the /etc/fstab file.

The default syntax for fstab entry of NFS mounts is as follows.

Server:/path/to/export /local_mountpoint nfs <options> 0 0

Server: This should be replaced with the exact hostname or IP address of the NFS server where the exported directory resides.

/path/to/export: This should be replaced with the exact shared directory (exported folder) path.

/local_mountpoint: This should be replaced with an existing directory in the server where you want to mount the NFS share.

Fstab NFS options

You can specify a number of options that you want to set on the NFS mount. We will go through the important mount options which you may consider while mounting a NFS share.

1) Soft/hard

When the mount option ‘hard’ is set, if the NFS server crashes or becomes unresponsive, the NFS requests will be retried indefinitely. You can set the mount option ‘intr’, so that the process can be interrupted. When the NFS server comes back online, the process can be continued from where it was while the server became unresponsive.

When the option ‘soft’ is set, the process will be reported an error when the NFS server is unresponsive after waiting for a period of time (defined by the ‘timeo’ option). In certain cases ‘soft’ option can cause data corruption and loss of data. So, it is recommended to use hard and intr options.

2) timeo=n

This option defines the time (in tenths of a second) the NFS client waits for a response before it retries an NFS request.

3) intr

This allows NFS requests to be interrupted if the server goes down or cannot be reached. Using the intr option is preferred to using the soft option because it is significantly less likely to result in data corruption.

4) rsize=num and wsize=num

This defines the maximum number of bytes in each READ/WRITE request that the NFS client can receive/send when communicating with a NFS server. The rsize/wsize value is a positive integral multiple of 1024. Specified rsize values lower than 1024 are replaced with 4096; values larger than 1048576 are replaced with 1048576. If a specified value is within the supported range but not a multiple of 1024, it is rounded down to the nearest multiple of 1024.

5) retrans=n

The number of times the NFS client retries a request before it attempts further recovery action. If the retrans option is not specified, the NFS client tries each request three times. The NFS client generates a "server not responding" message after retrans retries, then attempts further recovery (depending on whether the hard mount option is in effect).

6) noexec

Prevents execution of binaries on mounted file systems. This is useful if the system is mounting a non-Linux file system via NFS containing incompatible binaries.

7) nosuid

Disables set-user-identifier or set-group-identifier bits. This prevents remote users from gaining higher privileges by running a setuid program.

8) tcp

This specifies the NFS mount to use the TCP protocol.

9) udp

This specifies the NFS mount to use the UDP protocol.

Sample NFS fstab entry

A sample fstab entry for NFS share is as follows. /mnt/home nfs rw,hard,intr,rsize=8192,wsize=8192,timeo=14 0 0

This will make the export directory “/home” to be available on the NFS client machine. You can mount the NFS share just like you mount a local folder.

mount /mnt/home

Read Also:

8 Comments... add one

  1. Thank you for this article. It's important to have a handy doc showing the various options for those of us who don't do this every day. Your explanation (reminder) of the details of the various options is easy to understand, too.


    • # device mounting_directory filesystem_type options dump fsck

      Above is the fstab fields.

      Last two options are for 'dump' and 'fsck'

      dump - if you set to '1' - advise system to take backup of filesystem using dump utility on boot
      if you set to '0' - filesystem backup is ignored on boot

      fsck - if you set to '1' - advise system to do fsck on the first partition (root partition) on boot
      if you set to '2' - advise system to do fsck on all rest partition marked '2' in sequence on boot
      if you set to '0' - fsck will be ignored


Leave a Comment