Network File System (NFS) : Tom Rhodes Bill Swingle
Network File System (NFS) : Tom Rhodes Bill Swingle
FreeBSD supports the Network File System (NFS), which allows a server to
share directories and files with clients over a network. With NFS, users and
programs can access files on remote systems as if they were stored locally.
NFS has many practical uses. Some of the more common uses include:
NFS consists of a server and one or more clients. The client remotely
accesses the data that is stored on the server machine. In order for this to
function properly, a few processes have to be configured and running.
These daemons must be running on the server:
Daemon
nfsd
mountd
rpcbind
Description
The NFS daemon which services requests from NFS clients.
The NFS mount daemon which carries out requests received from nfsd.
This daemon allows NFS clients to discover which port the NFS server is using.
Running nfsiod(8) on the client can improve performance, but is not required.
28.3.1. Configuring the Server
The file systems which the NFS server will share are specified in /etc/exports.
Each line in this file specifies a file system to be exported, which clients have
access to that file system, and any access options. When adding entries to
this file, each exported file system, its properties, and allowed hosts must
occur on a single line. If no clients are listed in the entry, then any client on the
network can mount that file system.
The following /etc/exports entries demonstrate how to export file systems. The
examples can be modified to match the file systems and client names on the
reader's network. There are many options that can be used in this file, but only
a few will be mentioned here. See exports(5) for the full list of options.
This example shows how to export /cdrom to three hosts named alpha, bravo,
and charlie:
/cdrom -ro alpha bravo charlie
The -ro flag makes the file system read-only, preventing clients from making
any changes to the exported file system. This example assumes that the host
names are either in DNS or in /etc/hosts. Refer to hosts(5) if the network does
not have a DNS server.
The next example exports /home to three clients by IP address. This can be
useful for networks without DNS or /etc/hosts entries. The -alldirs flag allows
subdirectories to be mount points. In other words, it will not automatically
mount the subdirectories, but will permit the client to mount the directories that
are required as needed.
/usr/home
-alldirs
This next example exports /a so that two clients from different domains may
access that file system. The -maproot=root allows root on the remote system to
write data on the exported file system as root. If -maproot=root is not specified,
the client's root user will be mapped to the server's nobody account and will be
subject to the access limitations defined for nobody.
/a
-maproot=root
host.example.com box.example.org
A client can only be specified once per file system. For example, if /usr is a
single file system, these entries would be invalid as both entries specify the
same host:
# Invalid when /usr is one file system
/usr/src
client
/usr/ports client
client
/usr
client01
client02
client01 client02
/exports/obj -ro
To enable the processes required by the NFS server at boot time, add these
options to /etc/rc.conf:
rpcbind_enable="YES"
nfs_server_enable="YES"
mountd_flags="-r"
The client now has everything it needs to mount a remote file system. In these
examples, the server's name is server and the client's name is client. To
mount /home on server to the /mnt mount point on client:
# mount server:/home /mnt
/mnt
nfs
rw
A domain is defined as a logical group of network objects (computers, users, devices) that
share the same active directory database