Find Detailed NFS Mount Options in Linux

Here I will discuss the different NFS mount options you have to perform on nfs client. NFS is a client and server architecture based protocol, developed by Sun Microsystems. The main purpose of this protocol is sharing file/file system over the network between two UNIX/Linux machines. Users on a client computer can access remote file system over a network in a manner similar way they access a local filesystem.

Assuming that HOST A (NFS Server) running NFS service (rpc.mountd, nfsd, rpc.rquotad). Also, you can confirm by executing the following command on the NFS Server.

# service nfs status
rpc.mountd (pid 2919) is running...
nfsd (pid 2916 2915 2914 2913 2910 2909 2908 2907) is running...
rpc.rquotad (pid 2903) is running...

Now login to the HOST B (NFS Client) execute the following command, to find out shared directories in the NFS Server.

# showmount -e 192.168.1.4
Export list for 192.168.1.4:
/mnt/array1/RHEL5 192.168.1.0/255.255.255.0
/mnt/array1/RHEL632 192.168.1.0/255.255.255.0

While entering showmount command, you have to specify IP/Hostname (FQDN) of the NFS Server. After getting exported file system information, you can access by the mount command.

# mount -t nfs 192.168.1.4:/mnt/array1/RHEL5 /data/

Before mounting remote file system, first create a mount point, here I have created /data directory and mounted remote file system.

Syntax:

#mount -t vfstype [-o options] NFS Servername:/exporteddirectory /mount point

or

#mount -t nfs -o options host:/remote/export /local/directory

Options:

-t - Option specifies the type of the file system that is NFS.
-o intr—this option is used in a non-reliable network, or network having more network congestion. NFS request will be interrupted when the server is not reachable.

Example:

# mount -t nfs -o intr 192.168.1.4:/mnt/array1/RHEL5 /data/
# mount | grep -i intr
192.168.1.4:/mnt/array1/RHEL5 on /data type nfs (rw,intr,addr=192.168.1.4)

Hard  & Soft

Hard – if the hard option is specified during NFS mount, the user cannot terminate the process waiting for NFS communication to resume.

Example:

# mount -t nfs -o hard 192.168.1.4:/mnt/array1/RHEL5 /data/
# mount | grep -i hard
192.168.1.4:/mnt/array1/RHEL5 on /data type nfs (rw,hard,addr=192.168.1.4)

Soft- if the soft option is specified during NFS mount, the user will get error alert when NFS server is not reachable.

Example:

# mount -t nfs -o soft 192.168.1.4:/mnt/array1/RHEL5 /data/
# mount | grep -i soft
192.168.1.4:/mnt/array1/RHEL5 on /data type nfs (rw,soft,addr=192.168.1.4)

Nfsvers=value-- if this option is specified during NFS mount NFS client uses particular NFS protocol version to communicate.

Example:

# mount -t nfs -o nfsvers=3 192.168.1.4:/mnt/array1/RHEL5 /data/
# mount | grep -i nfsvers
192.168.1.4:/mnt/array1/RHEL5 on /data type nfs (rw,nfsvers=3,addr=192.168.1.4)

TCP / UDP

TCP or UDP: As said above, NFS is client and server architecture based protocol and it can be used transport layer as TCP and UDP both depend upon the application requirement.

Example: TCP

# mount -t nfs -o tcp 192.168.1.4:/mnt/array1/RHEL5 /data/
# mount | grep -i tcp
192.168.1.4:/mnt/array1/RHEL5 on /data type nfs (rw,tcp,addr=192.168.1.4)

Example: UDP

# mount -t nfs -o udp 192.168.1.4:/mnt/array1/RHEL5 /data/
# mount | grep -i udp
192.168.1.4:/mnt/array1/RHEL5 on /data type nfs (rw,udp,addr=192.168.1.4)

read/write (rw)  read-only (ro):

The rw option is used  for data that needs to be modified by users

# mount -t nfs -o rw 192.168.1.4:/mnt/array1/RHEL5 /data/

The ro option is used for data meant for viewing only. This option is used when you don't want the data to be altered to maintain the original version intact.

# mount -t nfs -o ro 192.168.1.4:/mnt/array1/RHEL5 /data/

nolock

This option disables file locking. The setting is occasionally used when connecting to older NFS servers.

# mount -t nfs -o nolock 192.168.1.4:/mnt/array1/RHEL5 /data/</>

remount

If a  file system is mounted read-only, the remount option remounts it read/write. This allows you to change the access permissions from read-only to read and write without forcing all users to leave the mounted directory or killing all processes using it.

# mount -t nfs -o remount 192.168.1.4:/mnt/array1/RHEL5 /data/

noexec

This option prevents the execution of binaries on mounted file systems. This comes in handy if your system is mounting a non-Linux file system via NFS which contains incompatible binaries.

# mount -t nfs -o noexec 192.168.1.4:/mnt/array1/RHEL5 /data/

nosuid

This option will disable SUID or SUIG bits. It prevents users from escalating privileges by running a setuid program

# mount -t nfs -o nosuid 192.168.1.4:/mnt/array1/RHEL5 /data/

sec=mode

This is a parameter used to specify the security type to use during authentication with an NFS connection

sec=sys — This is the default setting that makes use of local UNIX UIDs and GIDs by use of AUTH_SYS for authentication with NFS operations.

sec=krb5 Makes use of  Kerberos V5 instead of local UNIX UIDs and GIDs for authentication

sec=krb5i This setting utilizes Kerberos V5 for user authentication & conducts integrity checking of NFS operations using secure checksums to avert tampering of data.

sec=krb5p This utilizes Kerberos V5 for user authentication, integrity checking, and as well as encryption of  NFS traffic to prevent traffic sniffing. This is the most secure setting, but it also has the most performance overhead involved.

# mount -t nfs -o sec=krb5p 192.168.1.4:/mnt/array1/RHEL5 /data/

rsize=num and wsize=num

These settings are used to speed up NFS communication for reads (rsize) and writes (wsize) . This is achieved by setting a larger data block size, in bytes, to be transferred at one time. Caution should be taken when changing these values; some older Linux kernels and network cards are not compatible with larger block sizes. For NFSv2 or NFSv3, the default values for both parameters is set to 8192. For NFSv4, the default values for both parameters is set to 32768.

retry=n

The number of times the NFS client attempts to mount a directory after the first attempt fails. By default, this value is 1

# mount -t nfs -o retry=10 192.168.1.4:/mnt/array1/RHEL5 /data/

retrans=n

This refers to the number of times that an NFS request (a read or write request to a mounted directory) is retransmitted after it times out. Should the request not succeed after n retransmissions, a soft mount returns an error, and a hard mount retries the request. The default retrans value is 4

# mount -t nfs -o retrans=8 192.168.1.4:/mnt/array1/RHEL5 /data/

acdirmax=n

This refers to the maximum number of seconds a directory’s attributes are cached on the NFS client. The default value of this attribute is 60. if the timeout period expires, the client flushes its attribute cache, and if the attributes have changed, the client sends them to the NFS server.
– For a directory that seldom changes or that is owned and modified by only one user, like a user’s home directory,  decrease the load on your network by setting acdirmax=120 or higher.

# mount -t nfs -o acdirmax=120 192.168.1.4:/mnt/array1/RHEL5 /data/

acdirmin=n

This is the opposite of acdirmax. It is the minimum number of seconds a directory's attributes are cached on the NFS client. The default value for this attribute is acdirmin-30.  For a directory that seldom changes or that is owned and modified by only one user, like a user’s home directory,  decrease the load on your network by setting this attribute to acdirmin=60

# mount -t nfs -o acdirmin=80 192.168.1.4:/mnt/array1/RHEL5 /data/

acregmax=n

This refers to the maximum number of seconds a file’s attributes are cached on the NFS client. Should the timeout period expire, the client flushes its attribute cache, and if the attributes have been altered, the client sends them to the NFS server.
For a file that rarely changes or that is owned and modified by only one user, like a file in a user’s home directory,  decrease the load on your network by setting the acregmax=120 or higher.

# mount -t nfs -o acregmax=120 192.168.1.4:/mnt/array1/RHEL5 /data/

nocto

This option is used for a file or directory that remains static i.e never changes, to decrease the load on your network. The default value is not specified

# mount -t nfs -o retrans=8 192.168.1.4:/mnt/array1/RHEL5 /data/

Read Also:

Bobbin Zachariah 10:19 pm

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author's All Posts
Like to become part of Linoxide Team and contribute tips? Contact us here.

Comments

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.