Show Menu

fstab-nfs Cheat Sheet by

a quick reference for how to deal with nfs in an fstab file.
linux     nfs     fstab

AUTO MOUNTING NFS SHARES IN /ETC/FSTAB

To mount an NFS share using fstab (/etc/­fstab) you need to know a few things, the hostname or IP address of the NFS server, the share name and where you intend to mount the share at. Next, add this line to the end of the /etc/fstab file:

host­nam­e_o­r_i­p:/­sha­re_name /yourm­oun­t_l­ocation nfs rsize=­819­2,w­siz­e=8­192­,ti­meo­=14­,intr 0 0


10.0.0.5­0:­/backup /nfs/b­ackup nfs rsize=­819­2,w­siz­e=8­192­,ti­meo­=14­,intr 0 0

When you are done, you can quickly refresh the fstab using the mount command

fstab Options common to all file-s­ystems

auto / noauto
With the auto option, the device will be mounted automa­tically at bootup or when the mount -a command is issued. auto is the default option. For the device not to be
dev / nodev
Interp­ret/do not interpret block special devices on the file-s­ystem.
exec / noexec
exec lets binaries that are on the partition be executed, whereas noexec is the opposite.
rw / ro
Mount the file-s­ystem in either read write or read only mode.
sync / async
How the input and output to the filesystem should be done. sync means it is done synchr­ono­usly.
suid / nosuid
Permit­/Block the operation of suid, and sgid bits.
user / users / nouser
user permits any user to mount the filesy­stem. This automa­tically implies noexec, nosuid, nodev unless overri­dden. If nouser is specified, only root can mount the filesy­stem. If users is specified, every user in group users will be able to unmount the volume.
defaults
Use default settings. Default settings are defined per file system at the file system level. The normal default for Ext3 file systems is (rw,su­id,­dev­,ex­ec,­aut­o,n­ous­er,­async)
owner (Linux­-sp­ecific)
Permit the owner of device to mount.
atime / noatime / relatime / strict­atime (Linux­-sp­ecific)
The Unix stat structure records when files are last accessed (atime), modified (mtime), and changed (ctime). One result is that atime is written every time a file is read, which has been heavily criticized for causing perfor­mance degrad­ation and increased wear.

File-s­yst­em-­spe­cific options

ext2
check=­{none, normal, strict}
Sets the fsck checking level.
 
debug
Print debugging info on each remount .
 
sb=n
n is the block which should be used as the superblock for the fs.
fat
check=­{r[­ela­xed], n[ormal], s[trict]}
Not the same as ext2, but rather deals with allowed filenames. See mount.
 
conv={­b[i­nary], t[ext], a[uto]}
Performs DOS <--­-> UNIX text file conver­sions automa­tic­ally. See mount.
fat, ntfs
window­s_names
Linux filesy­stems have a larger set of allowed characters in filenames. window­s_names restricts the set of allowed characters for the volume to only those acceptable by Windows. Note: though FAT/NTFS are the most common use case, this feature is not specif­ically restricted to those filesystem types.
 
uid=n, gid=n
Sets the user identi­fier, uid, and group identi­fier, gid, for all files on the filesy­stem.
 
umask=nnn, dmask=nnn, fmask=nnn
nfs
addr=ip
where 'ip' means IP address
 

nfs - fstab format and options for nfs

nfsvers=n
The NFS protocol version number used to contact the server's NFS service.
soft / hard
Determines the recovery behavior of the NFS client after an NFS request times out.
intr / nointr
This option is provided for backward compat­ibi­lity. It is ignored after kernel 2.6.25.
timeo=n
The time in decise­conds (tenths of a second) the NFS client waits for a response before it retries an NFS request. For NFS over TCP the default timeo value is 600 (60 seconds).
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.
rsize=n
The maximum number of bytes in each network READ request that the NFS client can receive when reading data from a file on an NFS server.
wsize=n
The maximum number of bytes per network WRITE request that the NFS client can send when writing data to a file on an NFS server.
actimeo=n
Using actimeo sets all of acregmin, acregmax, acdirmin, and acdirmax to the same value.
bg / fg
Determines how the mount command behaves if an attempt to mount an export fails.
retry=n
The number of minutes that the mount command retries an NFS mount operation in the foreground or background before giving up.
# Examples

server­:path /mount­point fstype option­,op­tio­n,... 0 0

The following example from an /etc/fstab file causes the mount command to negotiate reasonable defaults for NFS behavior.
server­:/e­xport /mnt nfs defaults 0 0

This example can be used to mount /usr over NFS.
server­:/e­xport /usr nfs ro,nol­ock­,no­cto­,ac­tim­eo=3600 0 0

additional info:
https:­//w­ww.s­ys­tut­ori­als.co­m/d­ocs­/li­nux­/ma­n/5­-nfs/

Config­uration Options NFS side

rw
This option gives the client computer both read and write access to the volume.
sync
This option forces NFS to write changes to disk before replying. This results in a more stable and consistent enviro­nment since the reply reflects the actual state of the remote volume. However, it also reduces the speed of file operat­ions.
no_sub­tre­e_check
This option prevents subtree checking, which is a process where the host must check whether the file is actually still available in the exported tree for every request. This can cause many problems when a file is renamed while the client has it opened. In almost all cases, it is better to disable subtree checking.
no_roo­t_s­quash
By default, NFS translates requests from a root user remotely into a non-pr­ivi­leged user on the server. This was intended as security feature to prevent a root account on the client from using the file system of the host as root. no_roo­t_s­quash disables this behavior for certain shares.
example:
in the file /etc/e­xport

# the location | the network | the options |
/mount­/folder 192.16­8.1.0/­24(­rw,­syn­c,n­o_r­oot­_sq­uash)

Sample NFS fstab entry

To mount an export using NFS version 2, use the nfs file system type and specify the nfsvers=2 mount option. To mount using NFS version 3, use the nfs file system type and specify the nfsvers=3 mount option. To mount using NFS version 4, use either the nfs file system type, with the nfsvers=4 mount option, or the nfs4 file system type. The following example from an /etc/fstab file causes the mount command to negotiate reasonable defaults for NFS behavior.
A sample fstab entry for NFS share is as follows
serv­e­r:­­/export /mnt nfs defaults 0 0
host.my­ser­ver.co­m:/home /mnt/home nfs rw,har­d,i­ntr­,rs­ize­=81­92,­wsi­ze=­819­2,t­imeo=14 0 0

Download the fstab-nfs Cheat Sheet

3 Pages
//media.cheatography.com/storage/thumb/baa_fstab-nfs.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          mod_rewrite Cheat Sheet
          Vim NERDTree Cheat Sheet