Server Configuration
/etc/exports
contains the exported
directories on NFS servers. Refer to the exports.5
manual page for the syntax of this
file. Also refer to the "NFS HowTo" available at http://nfs.sourceforge.net/nfs-howto/
for information on how to configure the servers and clients in a
secure manner. For example, for sharing the /home
directory over the local network, the
following line may be added:
cat >> /etc/exports << EOF
/home 192.168.0.0/24
(rw,subtree_check,anonuid=99,anongid=99)
EOF
Note
Be sure to replace the directory, network address. and prefix
above to match your network. The only space in the line above
should be between the directory and the network address.
Install the NFSv4 server units
included in the blfs-systemd-units-20191026 package to
start the server at boot.
make install-nfsv4-server
If you have disabled NFSv4 support, run the following command
as the root
user to omit the
NFSv4 specific systemd units:
make install-nfs-server
You can edit the /etc/default/nfs-utils
file to change the
startup options for NFS daemons. Defaults should be fine for
most use cases.
Client Configuration
/etc/fstab
contains the directories
that are to be mounted on the client. Alternately the partitions
can be mounted by using the mount command with the proper
options. To mount the /home
and
/usr
partitions, add the following
to the /etc/fstab
:
<server-name>
:/home /home nfs rw,_netdev 0 0
<server-name>
:/usr /usr nfs ro,_netdev 0 0
The options which can be used are specified in man 5 nfs. If both the client
and server are running recent versions of linux, most of the
options will be negotiated (but see the Note above on nfsver=3).
You can specify either rw
or
ro
, _netdev
if the filesystem is to be automatically
mounted at boot, or noauto
(and
perhaps user
) for other filesystems.
If the fileserver is not running a recent version of linux, you
may need to specifiy other options.
If you are using systemd, you may need to enable autofs v4 in
your kernel, and add the option comment=systemd.automount
. Some machines need
this, because systemd tries to mount the external fs's before the
network is up, others do not need it. An alternative is for
root
to run mount -a.
Note
The following systemd units are
not required if the nfs-server units
are installed.
Install the units included in the
blfs-systemd-units-20191026
package to start the client services at boot.
make install-nfs-client