NFS Micro-HOWTO
Read http://tldp.org/HOWTO/NFS-HOWTO/index.html or (locally) /usr/doc/Linux-HOWTOS/NFS-HOWTO
There are two systems involved:
- the "server" provides the storage space, and "export"s it to clients over the network
- the "client" "mount"s the "server"s exported storage space, so that it occupies part of the "client"s filesystem tree.
Both systems must be connected via TCP/IP, preferably on the same LAN.
On the server:
- set up /etc/exports to name server directories to be exported to NFS clients. See exports(5) for format
- set up /etc/hosts.allow to designate client systems permitted to access NFS exports. See hosts_access(5) for format
- set up /etc/hosts.deny to designate systems not permitted to access NFS exports. See hosts_access(5) for format
- start the server-side NFS services. On Slackware Linux, you do this by running
/etc/rc.d/rc.nfsd start
On the client:
- wait until all the server's NFS services are started
- start the client-side NFS services. On Slackware Linux, you do this by running
/etc/rc.d/rc.rpc start
, usually via/etc/rc.d/rc.inet1
- optionally, edit /etc/fstab to add NFS mounts. See fstab(5) for format
- mount remote NFS filesystem(s) to local mountpoint(s). see mount(8) for format
Caveats:
- client UID/GID may be used in file access requests; to avoid problems, ensure that the client UIDs and GIDs match the server UIDs and GIDs
- UID 0 / GID 0 is a special case
- Read the exports(5) "User ID Mapping" section for details, look for
root_squash/no_root_squash/all_squash
options
/etc/exports
exports(5) says:
Each line contains an export point and a whitespace-separated list of
clients allowed to mount the file system at that point. Each listed client
may be immediately followed by a parenthesized, comma-separated list of
export options for that client. No whitespace is permitted between a
client and its option list.Also, each line may have one or more specifications for default options
after the path name, in the form of a dash ("-") followed by an option
list. The option list is used for all subsequent exports on that line
only.Blank lines are ignored. A pound sign ("#") introduces a comment to
the end of the line. Entries may be continued across newlines using a
backslash. If an export name contains spaces it should be quoted using
double quotes. You can also specify spaces or other unusual character
in the export name using a backslash followed by the character code as
three octal digits.
The 'export point' named in the /etc/exports file will be a directory
that the server wishes to make public to one or more NFS clients.
The client system named in the /etc/exports file can be one of
- a single IP address (eg: 192.169.0.5)
- a range of IP addresses specified in netaddress/netmask format (eg: 192.168.0.0/24)
- a single hostname, such as an abbreviated name recognized by the resolver, or a fully-qualified domain name (eg: guest eg: guest.this.lan)
- a "wildcard" domain name, which is a node name containing the wildcard characters '*' and/or '?' (eg: *.this.lan (matches all .this.lan nodes) eg: gues?.this.lan (matches guest.this.lan and guess.this.lan) )
Multiple clients (and their applicable options) can be given in one /etc/exports
entry:
/home/guest guest.this.lan(rw,sync) guess.this.lan(ro)
Simple /etc/exports example:
/home/guest guest.this.lan(rw,sync)
which exports the server's /home/guest subdirectory to the client system
named guest.this.lan. The server will grant both read and write requests
from the client (rw), and will reply to the client only after the changes
have been committed to stable storage (sync).