NFS
It is important to know them NFS export and mount options especially when you are facing a performance issue or a functional issue with the NFS mount over network.
Basic command
Commands | Description | Command on |
---|---|---|
# exportfs -r | Re-export your shares | Server |
# exportfs -a | Export your shares | Server |
# exportfs -v | Verify the NFS Share permissions | Server |
$nfsstat -m | Verify Current NFS Mount Options | Client |
NFS export on Server[1]
NFS exports options are the permissions that is applied on NFS Server when we create a NFS Share under /etc/exports
Here are most common(important) options that administrator must understand, full list of options are available on the man pages
Export Options | NFS Server | Default |
---|---|---|
secure/insecure
|
NFSv4 only uses port 2049 while to check the list of ports used by NFSv3 use in server port
With |
secure
|
rw/ro | ro means read-only access to the NFS Share
rw means read write access to the NFS Share |
|
root_squash/no_root_squash | squash literally means to squash (destroy) the power of the remote root user.
|
|
all_quash/no_all_squash | all_squash will map all User IDs (UIDs) and group IDs (GIDs) to the anonymous user. all_squash is useful for NFS-exported public FTP directories, news spool directories
|
no_all_squash
|
sync/aysnc | sync reply to requests are done only after the changes have been committed to stable storage
Using |
Check exports list and options
#with following set
$ cat /etc/exports
/nas * (rw,sync,no_root_squash,no_subtree_check)
$ rpcinfo -p | grep -i nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100003 3 udp 2049 nfs
# detailed export status with default export options
$ sudo exportfs -v
/nas <world>(ro,wdelay,root_squash,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)
NFS mount on Client[2]
# mount -t nfs -o [options] remote:/nfs /mount
Mount Options | NFS Client | Default |
---|---|---|
vers=n | The version of the NFS protocol to use. By default, the local NFS client will attempt to mount the file system using NFS version 3. If the NFS server does not support version 3, the file system will be mounted using version 2.
If you know that the NFS server does not support version 3, specify vers=2, and you will save time during the mount, because the client will not attempt to use version 3 before using version 2 |
3 |
rw (read/write) / ro (read-only) |
|
rw. |
suid / nosuid |
|
suid |
hard / soft |
|
hard |
intr / nointr |
|
intr |
fg (foreground) / bg (background) |
|
fg |
devs / nodevs |
|
devs |
timeo=n | The timeout, in tenths of a second, for NFS requests (read and write requests to mounted directories). If an NFS request times out, this timeout value is doubled, and the request is retransmitted. After the NFS request has been retransmitted the number of times specified by the retrans option, a soft mount returns an error, and a hard mount retries the request. The maximum timeo value is 30 (3 seconds).
– Try doubling the timeo value if you see several servers not responding messages within a few minutes. This can happen because you are mounting directories across a gateway, because your server is slow, or because your network is busy with heavy traffic. |
7 |
retrans=n | The number of times an NFS request (a read or write request to a mounted directory) is retransmitted after it times out. If the request does not succeed after n retransmissions, a soft mount returns an error, and a hard mount retries the request.
Increase the retrans value for a directory that is soft-mounted from a server that has frequent, short periods of downtime. This gives the server sufficient time to recover, so the soft mount does not return an error |
4 |
retry=n | The number of times the NFS client attempts to mount a directory after the first attempt fails. If you specify intr, you can interrupt the mount before n retries. However, if you specify nointr, you must wait until n retries have been made, until the mount succeeds, or until you reboot the system.
If mounts are failing because your server is very busy, increasing the retry value may fix the problem |
1 |
rsize=n | The number of bytes the NFS client requests from the NFS server in a single read request.
If packets are being dropped between the client and the server, decrease rsize to 4096 or 2048. To find out whether packets are being dropped, issue the “nfsstat -rc” command at the HP-UX prompt. If the timeout and retrans values returned by this command are high, but the badxid number is close to zero, then packets are being dropped somewhere in the network. |
8192 |
wsize=n | The number of bytes the NFS client sends to the NFS server in a single write request.
If packets are being dropped between the client and the server, decrease wsize to 4096 or 2048. To find out whether packets are being dropped, issue the “nfsstat -rc” command at the HP-UX prompt. If the timeout and retrans values returned by this command are high, but the badxid number is close to zero, then packets are being dropped somewhere in the network. |
8192 |
O (Overlay mount) | Allows the file system to be mounted over an existing mount point, making the underlying file system inaccessible. If you attempt to mount a file system over an existing mount point without the -O option, the mount will fail with the error device busy.
Caution: Using the -O mount option can put your system in a confusing state. The -O option allows you to hide local data under an NFS mount point without receiving any warning. Local data hidden beneath an NFS mount point will not be backed up during regular system backups. On HP-UX, the -O option is valid only for NFS-mounted file systems. For this reason, if you specify the -O option, you must also specify the -F nfs option to the mount command or the nfs file system type in the /etc/fstab file. |
The default value is not specified |
remount | If the file system is mounted read-only, this option remounts it read/write. This allows you to change the access permissions from read-only to read/write without forcing everyone to leave the mounted directory or killing all processes using it | The Default value is not specified |
noac | If specified, this option prevents the NFS client from caching attributes for the mounted directory.
Specify noac for a directory that will be used frequently by many NFS clients. The noac option ensures that the file and directory attributes on the server are up to date, because no changes are cached on the clients. However, if many NFS clients using the same NFS server all disable attribute caching, the server may become overloaded with attribute requests and updates. You can also use the actimeo option to set all the caching timeouts to a small number of seconds, like 1 or 3. If you specify noac, do not specify the other caching options. |
The Default value is not specified |
nocto | If specified, this option suppresses fresh attributes when opening a file.
Specify nocto for a file or directory that never changes, to decrease the load on your network |
The Default value is not specified |
acdirmax=n | The maximum number of seconds a directory’s attributes are cached on the NFS client. When this 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 rarely changes or that is owned and modified by only one user, like a user’s home directory, you can decrease the load on your network by setting acdirmax=120 or higher |
60 |
acdirmin=n | The minimum number of seconds a directory’s attributes are cached on the NFS client. If the directory is modified before this timeout expires, the timeout period is extended by acdirmin seconds.
For a directory that rarely changes or that is owned and modified by only one user, like a user’s home directory, you can decrease the load on your network by setting acdirmin=60 or higher |
30 |
acregmax=n | The maximum number of seconds a file’s attributes are cached on the NFS client. When this 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 file that rarely changes or that is owned and modified by only one user, like a file in a user’s home directory, you can decrease the load on your network by setting acregmax=120 or higher |
60 |
actimeo=n | Setting actimeo to n seconds is equivalent to setting acdirmax, acdirmin, acregmax, and acregmin to n seconds.
Set actimeo=1 or actimeo=3 for a directory that is used and modified frequently by many NFS clients. This ensures that the file and directory attributes are kept reasonably up to date, even if they are changed frequently from various client locations. Set actimeo=120 or higher for a directory that rarely or never changes. If you set the actimeo value, do not set the acdirmax, acdirmin, acregmax, or acregmin values |
The Default value is not specified |
grpid | Forces a newly created file in the mounted file system to inherit the group ID of the parent directory.
By default, a newly created file inherits the effective group ID of the calling process, unless the GID bit is set on the parent directory. If the GID bit is set, the new file inherits the group ID of the parent directory |
The Default value is not specified |