27.5.1 Exporting File Systems with NFSv4
NFSv4 is the latest version of NFS protocol available on openSUSE.
Configuring the directories for export with NFSv4 differs slightly from
the previous NFS versions.
The /etc/exports File
This file contains a list of entries. Each entry indicates a directory
that is shared and how it is shared. A typical entry in
/etc/exports consists of:
/shared/directory host(option_list)
For example:
/export 192.168.1.2(rw,fsid=0,sync)
/data 192.168.1.2(rw,bind=/export/data,sync)
For those directories— called pseudo root file system—
fsid=0 is specified in the option list. Here, the IP
address 192.168.1.2 is used. You can use the name of
the host, a wild card indicating a set of hosts
(*.abc.com, *, etc.), or
netgroups.
For a fixed set of clients, there are only two types of directories
that can be NFSv4 exported:
-
A single directory that is chosen as the pseudo root file system. In
this example, /export is the pseudo root
directory because fsid=0 is specified in the
option list for this entry.
-
Directories that are chosen to be bound to some existing subdirectory
of the pseudo file system. In the example entries above,
/data is such a directory that binds to an
existing subdirectory (/export/data) of the
pseudo file system /export.
The pseudo file system is the top level directory under which all file
systems that need to be NFSv4 exported take their places. For a client
or set of clients, there can only be one directory on the server
configured as the pseudo root for export. For this client or client
set, multiple other directories can be exported by binding them to some
existing subdirectory in the pseudo root.
/etc/sysconfig/nfs
This file contains a few parameters that determine NFSv4 server daemon
behavior. Importantly, the parameter NFSv4_SUPPORT must be set to yes.
This parameter determines whether the NFS server supports NFSv4 exports
and clients.
/etc/idmapd.conf
Every user on a Linux machine has a name and ID. idmapd does the
name-to-ID mapping for NFSv4 requests to the server and replies to the
client. This must be running on both server and client for NFSv4,
because NFSv4 uses only names for its communication.
Make sure that there is a uniform way in which usernames and IDs (uid)
are assigned to users across machines that might probably be sharing
file systems using NFS. This can be achieved by using NIS, LDAP, or any
uniform domain authentication mechanism in your domain.
For proper function, the parameter Domain must be
set the same for both, client and server in this file. If you are not
sure, leave the domain as localdomain in the server
and client files. A sample configuration file looks like the following:
[General]
Verbosity = 0
Pipefs-Directory = /var/lib/nfs/rpc_pipefs
Domain = localdomain
[Mapping]
Nobody-User = nobody
Nobody-Group = nobody
Do not change these parameters unless you know exactly what you are
doing. For further reference, read the man page of
idmapd and idmapd.conf;
man idmapd, man idmapd.conf.
Starting and Stopping Services
After changing /etc/exports or
/etc/sysconfig/nfs, start or restart the nfs
server service with rcnfsserver restart. After
changing /etc/idmapd.conf, reload the
configuration file with the command killall -HUP
rpc.idmapd.
If this service should start at boot time, run the command
chkconfig nfsserver on.
27.5.2 Exporting File Systems with NFSv2 and NFSv3
This is specific to NFSv3 and NFSv2 exports. Refer to
Exporting for NFSv4 Clients for
exporting with NFSv4.
Exporting file systems with NFS involves two configuration files:
/etc/exports and
/etc/sysconfig/nfs. A typical
/etc/exports file entry is in the format:
/shared/directory host(list_of_options)
For example:
/export 192.168.1.2(rw,sync)
Here, the directory /export is shared with the host
192.168.1.2 with the option list rw,sync. This
IP address can be replaced with a client name or set of clients using a
wild card (such as *.abc.com) or even netgroups.
For a detailed explanation of all options and their meanings, refer to
the man page of exports (man
exports).
After changing /etc/exports or
/etc/sysconfig/nfs, start or restart the NFS server
using the command rcnfsserver restart.