 |
» |
|
|
 |
An NFS client is a system that mounts
remote directories using NFS. When a client mounts a remote filesystem,
it does not make a copy of the filesystem. The mounting process uses
a series of remote procedure calls that enable the client to transparently
access the filesystem on the server’s disk. To users, these
mounted remote directories appear as if they are a part of the local
filesystem. An NFS client can also be an NFS server. NFS filesystems
can also be automounted using AutoFS. For information on how to automount
a filesystem, see Chapter 3: “Configuring and Administering AutoFS”. NFS Client Configuration Files and Daemons |  |
This section describes the NFS client configuration files and
daemons. Configuration FilesTable 2-5 describes the
NFS configuration files and their functions. Table 2-5 NFS client configuration files File Name | Function |
|---|
| /etc/mnttab | Contains the list of filesystems that
are currently mounted. | | /etc/dfs/fstypes | Contains the default distributed filesystem
type. | /etc/fstab | Contains the list of filesystems
that are automatically mounted at system boot time. |
DaemonsTable 2-5 describes the NFS client daemons and their functions. Table 2-6 NFS client daemons Daemon Name | Function |
|---|
| rpc.lockd | Supports record lock and share lock operations
on the NFS files. | rpc.statd | Maintains a list of clients
that have performed the file locking operation over NFS against the
server. These clients are monitored and notified in the event of a
system crash. |
Following are the tasks involved in configuring and administering
an NFS client. Configuring the NFSv4 Client Protocol Version |  |
By default, the version of the NFS protocol used between the
client and the server is the highest one available on both systems.
On HP-UX 11i v3, the default maximum protocol version of the NFS server
and client is 3. The default minimum protocol version of the NFS server
and client is 2. To configure the NFS client to enable it to mount filesystems
using protocol version 4 (NFSv4), follow this step: Set the value of the NFS_CLIENT_VERSMAX variable to 4 in the /etc/default/nfs file,
as follows: The NFS_CLIENT_VERSMAXvariable specifies
the maximum version of the NFS protocol for communication. You can also configure the client protocol version to NFSv4
by specifying vers=4 while mounting the directory.
For example, to set the client protocol version to NFSv4 while mounting
the /usr/kc directory, enter the following command: mount -o vers=4 serv:/usr/kc /usr/kc |
For more information on NFSv4, see nfsd(1m), mount_nfs(1m), nfsmapid(1m), and nfs4cbd(1m). Deciding Between Standard-Mounted Directories and Automounted
Directories |  |
Before you mount any remote directories on a local system, decide
whether you want each directory to be standard-mounted or automounted.
You can automount directories using AutoFS. For more information on
AutoFS, see Chapter 3: “Configuring and Administering AutoFS”. Table 2-7 lists the differences
between the Standard-Mounted and the Automounted directories. Table 2-7 Standard-Mounted Versus Automounted Directories Standard-Mounted Directory | Automounted Directory (Using AutoFS) |
|---|
The directory stays mounted. You do not have to
wait for it to be mounted after you issue a read or write request. | Automounted
directories stay mounted until they are left idle for 10 minutes.
The 10 minute time interval is the default value and is configurable. | If a directory is configured to be standard-mounted
when your system boots, and the NFS server for the directory is not
booted yet, system startup is delayed until the NFS server becomes
available. If your system and the server are configured to mount directories
from each other at boot time, standard mounts can cause both systems
to hang indefinitely. | A directory automounted
with AutoFS is not mounted until a user or a process requests access
to it. As a result, both your system and the NFS server are able to
complete the boot process before attempting to mount the directory. | You must maintain the configuration file for standard
mounts (/etc/fstab) separately on
each NFS client. | You can manage AutoFS configuration files (maps)
centrally through NIS and LDAP. | If you have to configure many similar standard
mounts, you must configure them individually, because you cannot use
wildcard characters or environment variables when you configure standard
NFS mounts. | AutoFS allows you to use wildcard characters and
environment variables in configuration files (maps) as shortcuts,
when you are configuring many similar automounts. | Standard NFS mounts provide no shortcut for configuring all
available remote directories. You must configure each directory separately.
If the NFS servers change the directories they are exporting, you
must change your local NFS client configuration. | AutoFS allows you to configure
a special “built-in” map known as the -hosts map. This built-in map automounts all the
exported directories from any NFS server on the network on your system
whenever anyone requests access to a directory on that server. The
servers can change which directories they export, but your configuration
remains valid. |
Enabling an NFS Client |  |
To enable an NFS client, follow these steps: In the /etc/rc.config.d/nfsconf file, set the value of NFS_CLIENT variable
to 1, as follows: Enter the following command to run the NFS client
startup script: /sbin/init.d/nfs.client start |
The NFS client startup script starts the necessary NFS client
daemons, and mounts the remote directories configured in the /etc/fstab file. Mounting Remote Directories |  |
The mount command mounts a shared NFS directory
from a remote system (NFS server). You can mount a filesystem using the following methods: Automatic Mounting at System Boot time To set up a filesystem for automatic mounting at system boot time,
you must configure it in the /etc/fstab file.
All filesystems specified in the /etc/fstab file
are mounted during system reboot. Manual Mounting When you manually mount
a filesystem, it is not persistent across reboots or when NFS client
restarts. If the NFS client is restarted or the system is rebooted,
the filesystem must be mounted again after the reboot. To mount filesystems
manually, you must run the mount command. For a
list of mount options, see mount_nfs(1M).
Consider the following points before you mount a directory: Before you mount a remote directory on your system,
you must configure the remote system as an NFS server and share the
directory. You must configure a local directory as the mount-point
for the NFS filesystem. HP recommends that the mount-point not contain
files and directories. However, if the local directory contains files
and directories, they will be hidden and inaccessible while the remote
directory is mounted.
Mounting a Remote Directory on an NFS clientTo mount a directory on an NFS client, select one of the following
methods: Automatic MountTo configure a remote directory to be automatically mounted
at system boot, follow these steps: Add an entry to the /etc/fstab file, for each remote directory you want to mount on your system.
Following is the syntax for the entry in the /etc/fstab file: server:remote_directory local_directory nfs defaults 0 0 |
or server:remote_directory local_directory nfs option[,option...] 0 0 |
Mount all the NFS file systems specified in the /etc/fstab file by entering the following command: /usr/sbin/mount -a -F nfs |
Verify that your filesystem is mounted by entering
the following command: An output similar to the following output is displayed: /mnt/nfs149 from nfs149:/
Flags:
vers=4,proto=tcp,sec=sys,hard,intr,link,symlink,devs,rsize=
32768,wsize=32768,retrans=5,timeo=600
Attr cache:acregmin=3,acregmax=60,acdirmin=30,acdirmax=60 |
The directory that you have mounted must be present in this
list.
Manual MountTo mount your directories manually, follow these steps: To mount a remote directory manually, enter the following
command: mount serv:directory_name directory-name |
Verify if your filesystem is mounted by entering the
following command: An output similar to the following output is displayed: /opt/nfstest from hpnfsweb:/home/tester
Flags:
vers=3,proto=udp,sec=sys,hard,intr,link,symlink,acl,devs,
rsize=32768,wsize=32768,retrans=5,timeo=11
Attr cache:
acregmin=3,acregmax=60,acdirmin=30,acdirmax=60
Lookups: srtt=33 (82ms), dev=33 (165ms), cur=20 (400ms) |
The directory that you have mounted must be present in this
list.
For a list of mount options, see mount_nfs(1M). Enabling Client-Side Failover |  |
Using client-side failover, an NFS client can switch to another
server if the server supporting a replicated filesystem becomes unavailable. The failover is usually transparent to the user. Failover can
occur at any time without disrupting the processes running on the
client. Failover is only supported on read-only fileystems. To mount a directory that has been replicated on multiple servers,
enter the following command: mount -o ro svr:dir_name,srv:dir_name dir_name |
If the first NFS server is down, the client accesses the second
NFS server. For example, to mount the Casey directory
to replicated servers, enter the following command: mount -o ro onc21:/home/Casey, onc23:/home/Casey /Clay |
If the NFS server onc21 is down, the client
accesses NFS server onc23. To verify if the failover is in effect, enter the following
command: An output similar to the following output is displayed: /Clay from onc21:/home/Casey,onc23:/home/Casey
Flags:
vers=3,proto=tcp,sec=sys,hard,intr,llock,link,symlink,acl,
devs,rsize=32768,wsize=32768,retrans=5,timeo=600
Attr cache: acregmin=3,acregmax=60,acdirmin=30,acdirmax=60
Failover: noresponse=0,failover=0,remap=0,currserver=atcux8 |
The Failover line in the above output indicates that the failover
is working. Mounting a directory as read-only with no set userid
privileges mount -r -o nosuid broccoli:/usr/share/man /usr/share/man |
In this example, the NFS clients mount the /usr/share/man directory from the NFS server broccoli. The local mount-point is also /usr/share/man. The directory is mounted as read-only. Figure 2-3 illustrates this
example. Mounting a Home directory mount -r -o nosuid broccoli:/home/broccoli /home/broccoli
mount -r -o nosuid cauliflower:/home/cauliflower /home/cauliflower |
In this example, the NFS client mounts the home directories
from NFS servers broccoli and cauliflower . The nosuid option prevents programs with setuid permission from executing on
the local client. Figure 2-4 illustrates this
example. Mounting an NFS Version 2 filesystem using the UDP
Transport mount -o vers=2,proto=udp onc21:/var/mail /var/mail |
In this example, the NFS client mounts the /var/mail directory from the NFS server, onc21, using NFSv2 and the UDP protocol. Mounting an NFS filesystem using an NFS URL mount nfs://onc31/Casey/mail /Casey/mail |
In this example, the NFS client mounts the /Casey/mail directory from NFS server, onc31, using the WebNFS protocol. Mounting an NFS filesystem by using a public file
handle mount -o public nfs://onc31/usr/%A0abc /Casey/Clay |
If the public option or a URL is specified,
the mount command attempts to connect to the server using the public
file handle. The daemonsrpcbind and mountd are not contacted. In this example, the NFS client mounts /Casey/Clay directory by using a public file handle, and an NFS URL that has
a non 7-bit ASCII escape sequence from the NFS server, onc31. Mounting an NFS filesystem using native path mount -o public onc31:C:Casey:test1 /Casey/test |
A native path is a pathname that is interpreted according to
conventions used on the native operating system of the NFS server. In this example, the NFS client mounts the /Casey/test directory using a native path and a public file handle. Mounting a replicated set of NFS filesystems with
same pathnames mount -r onc21,onc23,onc25:/Casey/Clay /Casey/Clay |
In this example, the NFS client mounts a single filesystem, /Casey/Clay that has been replicated to a number of servers
with the same pathnames. This enables the NFS client to failover to
either server onc21, onc23, or onc25 if the current server has become unavailable. Mounting replicated set of NFS file systems with different
pathnames mount -r onc21:/Casey/Clay,onc23:/Var/Clay,nfs://srv-z/Clay /Casey/Clay |
In this example, the NFS client mounts a replicated set of NFS
file systems with different pathnames.
Secure Mounting of Directories |  |
The mount command enables you to specify
the security mode for each NFS mount-point. This allows the NFS client
to request a specific security mode. However, if the specific mode
does not exist on the server, then the mount fails. Use the sec option to specify the security mode. If sec is not specified in NFSv2, then the
AUTH_SYS mode is used by default. If sec is not specified
in NFSv3, then the default action is for the NFS client to query the
server about the security mode to be used. The resulting security
mode is negotiated between the NFS client and server. For more information
on the available security modes, see nfssec(5). An Example for Securely Mounting a directoryIn the following example, the NFS client forces the use of krb5 as the secure mode. The krb5 secure mode uses the Kerberos V5 protocol to authenticate users
before granting access to the shared filesystems. In this example,
the NFS server, onc21, also supports
the same secure mode. mount -F nfs -o sec=krb5 onc21:/casey/nfs /casey/nfs |
Changing the Default Mount Options |  |
To change the default mount options, follow these steps: Modify the NFS mount options in the /etc/fstab file, or the AutoFS map, as needed. For
more information on the different mount options that NFS supports,
see mount_nfs(1M). If you changed the mount
options for a directory that is currently mounted, you must unmount
and remount it before the changes take effect. To unmount and remount
the directory, enter the following commands: /usr/sbin/umount local_directory
/usr/sbin/mount local_directory |
If you change the mount options in the AutoFS master
map, you must restart AutoFS for the changes to take effect. For information
on restarting AutoFS, see “Restarting AutoFS”.
For more information on the different caching mount options,
see mount_nfs(1M). Unmounting (Removing) a Mounted Directory |  |
You can temporarily unmount a directory using the umount command. If you want to stop a directory from being automatically
mounted upon server restart or system reboot, remove it from the /etc/fstab file.  |  |  |  |  | NOTE: Before you unmount a directory, run the fuser -cu command to determine whether the directory is currently in use.
The fuser command lists the process IDs and user
names of all the processes who are using the mounted directory. If
users are accessing the mounted directories, they must exit the directories
before you unmount the directory. |  |  |  |  |
To unmount a mounted directory and prevent it from being automatically
mounted, follow these steps: Automatic UnmountTo check for any processes accessing the mounted directory,
enter the following command: fuser -cu mounted_directory |
To kill the processes, enter the following command: fuser -ck local_mount_point |
Unmount the filesystem as follows: /usr/sbin/umount mounted_directory |
If the unmount fails, use the forcible option to unmount
the filesystem: /usr/sbin/umount -f mounted_directory |
Verify whether all the directories are unmounted by
entering the following command: The directories that you have unmounted must not be present
in the list displayed. If you do not want the directory to be automatically
mounted when the system is rebooted, remove the directory entry from
the /etc/fstab file.
Disabling NFS Client Capability |  |
To disable the NFS client, follow these steps: On the NFS client, enter the following command to
get a list of all the mounted NFS filesystems on the client For every NFS mounted directory listed by the nfsstat command, enter the following command to
determine whether the directory is currently in use: /usr/sbin/fuser -cu local_mount_point |
This command lists the process IDs and user names of all processes
currently using the mounted directory. To kill all processes that are using the mounted directory,
enter the following command: /usr/sbin/fuser -ck local_mount_point |
To unmount all NFS mounted directories, enter the
following command: To disable the NFS client and Autofs, edit the /etc/rc.config.d/nfsconf file on the client to set
the NFS_CLIENT and AUTOFSvariables to 0, as follows: NFS_CLIENT=0
AUTOFS=0
This prevents the client processes from starting up again when you reboot the client. |
Enter the following command to disable NFS client
capability: /sbin/init.d/nfs.client stop |
For more information, see umount
(1M), mount(1M), and fuser(1M).
|