Linux NFS Mount Entry In fstab ( /etc/fstab ) With Example

September 18, 2012 | By in FILE SYSTEM, LINUX HOWTO, NFS | 3 Replies More

NFS stands for ‘Network File System’. This mechanism allows unix machines to share files and directories over 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.

<options>: 

 You can specify a number of mount points which 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.

• Soft/hard :

When the mount option ‘hard’ is set, if the NFS server crashes or become 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.

• 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.

• 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.

• 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.

• 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).

• 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.

• nosuid :

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

• tcp -

This specifies the NFS mount to use the TCP protocol.

• 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.

host.myserver.com:/home /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

Tags: ,

Category: FILE SYSTEM, LINUX HOWTO, NFS

Comments (3)

Trackback URL | Comments RSS Feed

  1. common man says:

    useful doc.. tnx

  2. Sum Yung Gai says:

    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.

    --SYG

Leave a Reply

Commenting Policy:
Keywords instead of a real name? Comment gets deleted.
A fake name instead of your real name? Comment gets deleted.
1 liner "thank you" comment or offtopic? Comment gets deleted.
If the comment gets approved, we own all rights to it.
All comments are subject to moderation.