 |
» |
|
|
 |
An NFS client is a machine that "mounts"
remote directories using NFS. These mounted remote directories appear
to users as if they are part of the NFS client's local
file system. An NFS client can also be an NFS server. Following
are the tasks involved in configuring and administering an NFS client.
Only the first four tasks are required in order to get your client
up and running. This section tells you how to perform these tasks, by editing
files and issuing HP-UX commands. However, Hewlett-Packard recommends
that you use SAM to configure and administer NFS. SAM (System Administration
Manager) is Hewlett-Packard's windows-based user interface
for performing system administration tasks. To run SAM, type sam
at the HP-UX prompt. SAM has an extensive online help facility. To Decide Between Standard-Mounted
and Automounted Directories |  |
Before you mount any remote directories
on your local system, decide whether you want each directory to
be standard-mounted or automounted. Table 2-1 “Standard-Mounted vs. Automounted
Directories” lists the advantages and disadvantages
of each type of mount. For instructions on automounting remote directories,
see “Configuring and Administering
AutoFS”. Standard-mounted directories stay mounted until you explicitly
unmount them. Automounted directories stay mounted until they are
left idle for five minutes. The five minute default can be changed
by adding the -t duration
option to the AUTOMOUNT_OPTIONS
variable in the /etc/rc.config.d/nfsconf
file.
Table 2-1 Standard-Mounted vs. Automounted
Directories Standard-Mounted Directory | Automounted
Directory |
|---|
Advantage: Configuration
is simpler than for automounted directories. Only one file (/etc/fstab)
is used to configure standard mounts. | Disadvantage:
Configuration can be more complicated than for standard mounts.
Multiple files are usually required to configure AutoFS. | Advantage: The directory
stays mounted, so you never have to wait for it to be mounted after
you issue a read or write request. | Disadvantage:
If the automounted directory has timed out and been unmounted, and
you attempt to read it or write to it, you may have to wait a few
seconds for it to be mounted again. | Disadvantage: If a
directory is configured to be standard-mounted when your system
boots, and the NFS server for the directory is not booted yet, your
system will hang 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. | Advantage:
An automounted directory is not mounted until a user or process
requests access to it, so both your system and the NFS server will
have time to boot before any attempt is made to mount the directory. | Disadvantage: The
configuration file for standard mounts (/etc/fstab)
must be maintained separately on each NFS client. | Advantage:
AutoFS configuration files (maps) may be managed centrally through
NIS. | Disadvantage: Only
one NFS server may be configured for each standard-mounted directory. | Advantage:
Multiple servers may be configured for a single automounted directory,
for reliability and load balancing. All servers are polled simultaneously,
and the directory is mounted from the first server to respond. | Disadvantage: If you
have to configure many similar standard mounts, you must configure
each of them individually, because you cannot use wildcard characters
or environment variables when you configure standard NFS mounts. | Advantage:
AutoFS allows you to use wildcard characters and environment variables
in configuration files (maps) as shortcuts when you are configuring
many similar automounts. | Disadvantage:
Standard NFS mounts provide no shortcut for configuring all available
remote directories; each directory must be configured explicitly.
If the NFS servers change which directories they are exporting,
you must change your local NFS client configuration. | Advantage:
AutoFS allows you to configure a special "built-in"
map (the -hosts
map), which causes all the exported directories from any NFS server
on the network to be automounted on your system whenever anyone
requests access to a directory on that server. The servers can change
which directories they export, and your configuration remains valid. |
To Mount a Remote Directory
Using a Standard NFS Mount |  |
In the /etc/fstab
file, use a text editor to add a line for each remote directory
you want mounted on your system. If the /etc/fstab
file does not exist, you will have to create it. A line in the /etc/fstab
file has the following syntax: server:remote_directory local_directory nfs defaults 0 0 |
or server:remote_directory local_directory nfs option[,option...] 0 0 |
For descriptions of the mount options, see “To Change the Default
Mount Options”. If your system is already running as an NFS client,
issue the following command to mount each remote directory you have
added to the /etc/fstab
file: /usr/sbin/mount local_directory |
Or, issue the following command to mount all the directories
listed in the /etc/fstab
file:
The remote directories listed in the /etc/fstab
file will be mounted automatically when you enable NFS client capability
or reboot your system. See “To Enable NFS Client
Capability”. The local directory you configure as a mount point must exist
and should be empty. If the local mount point contains files or
directories, they will be hidden and inaccessible while the remote
directory is mounted over them. Before you can mount a remote directory on your system, the
remote system where the directory is located must be configured
as an NFS server and must export the directory. To mount a directory temporarily, issue the mount
command, but do not add the mount to the /etc/fstab
file. It will stay mounted until you reboot your system or until
you unmount it with the umount
command. For more information, type man 4 fstab
or man 1M mount
at the HP-UX prompt. Example NFS Mount of man pagesbroccoli:/usr/share/man /usr/share/man NFS ro 0 0 |
This example mounts the directory /usr/share/man
from the NFS server broccoli.
The local mount point is also /usr/share/man.
The directory is mounted read-only. Figure 2-2 “NFS Mount
of man pages” illustrates this example: Example NFS Mount of Home Directoriesbroccoli:/home/broccoli /home/broccoli nosuid 0 0 cauliflower:/home/cauliflower /home/cauliflower nosuid 0 0 |
This example mounts the home directories from NFS servers
broccoli and
cauliflower on
the local NFS client. The nosuid
option prevents programs with setuid permission from executing on
the local client. Figure 2-3 “NFS Mount
of Home Directories” illustrates
this example: To Enable NFS Client
Capability |  |
In the /etc/rc.config.d/nfsconf
file, make sure the NFS_CLIENT
variable is set to 1, as follows: Run the NFS startup script by issuing the following
command: /sbin/init.d/nfs.client start |
Setting the NFS_CLIENT
variable to 1 causes the NFS startup script to be run whenever you
reboot your system. The NFS startup script starts the necessary NFS client daemons
and mounts the remote directories configured in the /etc/fstab
file. To Verify Your NFS
Client Configuration |  |
After you have configured the directories
you want to mount and enabled NFS client capability, issue the ls
command in the local directories you have configured as NFS mount
points. If your NFS client is working correctly, the ls
command will list the contents of mounted directories. If the local
directories are empty, or if you get error messages, see Chapter 7 “Troubleshooting NFS
Services”.
To Change the Default
Mount Options |  |
Include the NFS mount options in your /etc/fstab
file or automounter map as needed. Table 2-2 “NFS Mount Options” and Table 2-3 “NFS Caching Options”
list the NFS mount options. If you changed the mount options in the automounter
master map, you must run the automount(1M)
command, on each client that uses the map, before your changes will
take effect. If you changed the mount options for a directory that is currently
mounted, you must unmount and remount it before your changes will
take effect. Issue the following commands: /usr/sbin/umount local_directory /usr/sbin/mount local_directory |
Table 2-2 NFS Mount Options rw
(read/write) or ro
(read-only)
(default: rw) | Use
rw for data that
users need to modify. In order for you to mount a directory read/write,
the NFS server must export it read/write. Use
ro for data you
do not want users to change. A directory that is automounted from
several servers should be read-only, to keep versions identical
on all servers. | suid
or nosuid (default:
suid) | Specify
suid if you want
to allow mounted programs that have setuid permission to run with
the permissions of their owners, regardless of who starts them.
If a program with setuid permission is owned by root, it will run
with root permissions, regardless of who starts it. Specify
nosuid to protect
your system against setuid programs that may run as root and damage
your system. | hard
or soft (default:
hard) | Specify
hard if users
will be writing to the mounted directory or running programs located
in it. When NFS tries to access a hard-mounted directory, it keeps
trying until it succeeds or someone interrupts its attempts. If
the server goes down, any processes using the mounted directory
hang until the server comes back up and then continue processing
without errors. Interruptible hard mounts may be interrupted with
CTRL-C or kill
(see the intr
option, later). Specify
soft if the server
is unreliable and you want to prevent systems from hanging when
the server is down. When NFS tries to access a soft-mounted directory,
it gives up and returns an error message after trying retrans
times (see the retrans
option, later). Any processes using the mounted directory will return
errors if the server goes down. | intr or nointr (default:
intr) | Specify
intr if users
are not likely to damage critical data by manually interrupting
an NFS request. If a hard mount is interruptible, a user may press
[CTRL]-C or issue
the kill command
to interrupt an NFS mount that is hanging indefinitely because a
server is down. Specify
nointr if users
might damage critical data by manually interrupting an NFS request,
and you would rather have the system hang while the server is down
than risk losing data between the client and the server. | fg
(foreground) or bg
(background) (default: fg) | Specify
fg for directories
that are necessary for the client machine to boot or operate correctly.
If a foreground mount fails, it is retried again in the foreground
until it succeeds or is interrupted. All automounted directories
are mounted in the foreground; you cannot specify the bg
option with automounted directories. Specify
bg for mounting
directories that are not necessary for the client to boot or operate
correctly. Background mounts that fail are retried in the background,
allowing the mount process to consider the mount complete and go
on to the next one. If you have two machines configured to mount
directories from each other, configure the mounts on one of the
machines as background mounts. That way, if both systems try to
boot at once, they will not become deadlocked, each waiting to mount
directories from the other. The bg
option cannot be used with automounted directories. | devs
or nodevs (default:
devs) | Specify
devs if you are
mounting device files from a server whose device files will work
correctly on the client. The devs
option allows you to use NFS-mounted device files to read and write
to devices from the NFS client. It is useful for maintaining a standard,
centralized set of device files, if all your systems are configured
similarly. Specify
nodevs if device
files mounted from a server will not work correctly for reading
and writing to devices on the NFS client. The nodevs
option generates an error if a process on the NFS client tries to
read or write to an NFS-mounted device file. | timeo=n (default=7) | The
timeout, in tenths of a second, for NFS requests (read and write
requests to mounted directories). If an NFS request times out, this
timeout value is doubled, and the request is retransmitted. After
the NFS request has been retransmitted the number of times specified
by the retrans
option (see below), a soft mount returns an error, and a hard mount
retries the request. The maximum
timeo value is 30 (3 seconds). Try
doubling the timeo
value if you see several server not responding
messages within a few minutes. This can happen because you are mounting
directories across a gateway, because your server is slow, or because
your network is busy with heavy traffic. | retrans=n (default=4) | The
number of times an NFS request (a read or write request to a mounted
directory) is retransmitted after it times out. If the request does
not succeed after n
retransmissions, a soft mount returns an error, and a hard mount
retries the request. Increase
the retrans value
for a directory that is soft-mounted from a server that has frequent,
short periods of down time. This gives the server sufficient time
to recover, so the soft mount does not return an error. | retry=n (default=1) | The
number of times the NFS client attempts to mount a directory after
the first attempt fails. If you specify intr,
you can interrupt the mount before n
retries. However, if you specify nointr,
you must wait until n
retries have been made, until the mount succeeds, or until you reboot
the system. If
mounts are failing because your server is very busy, increasing
the retry value
may fix the problem. | rsize=n (default=8192) | The
number of bytes the NFS client requests from the NFS server in a
single read request. If
packets are being dropped between the client and the server, decrease
rsize to 4096
or 2048. To find out whether packets are being dropped, issue the
nfsstat -rc command
at the HP-UX prompt. If the timeout
and retrans values
returned by this command are high, but the badxid
number is close to zero, then packets are being dropped somewhere
in the network. | wsize=n (default=8192) | The
number of bytes the NFS client sends to the NFS server in a single
write request. If
packets are being dropped between the client and the server, decrease
wsize to 4096
or 2048. To find out whether packets are being dropped, issue the
nfsstat -rc command
at the HP-UX prompt. If the timeout
and retrans values
returned by this command are high, but the badxid
number is close to zero, then packets are being dropped somewhere
in the network. | vers=n (default=3) | The version of the NFS protocol
to use. By default, the local NFS client will attempt to mount the
file system using NFS version 3. If the NFS server does not support
version 3, the file system will be mounted using version 2. If you
know that the NFS server does not support version 3, specify vers=2,
and you will save time during the mount, because the client will
not attempt to use version 3 before using version 2. | O
(Overlay mount) default: not specified | Allows the file system to
be mounted over an existing mount point, making the underlying file
system inaccessible. If you attempt to mount a file system over
an existing mount point without the -O
option, the mount will fail with the error device busy. Caution:
Using the -O mount option can put
your system in a confusing state. The -O
option allows you to hide local data under an NFS mount point without
receiving any warning. Local data hidden beneath an NFS mount point
will not be backed up during regular system backups. On
HP-UX, the -O option is valid only
for NFS-mounted file systems. For this reason, if you specify the
-O option, you must also specify
the -F nfs option to the mount
command or the nfs file system
type in the /etc/fstab file. | remount default:
not specified | If the file system is mounted
read-only, this option remounts it read/write. This allows you to
change the access permissions from read-only to read/write without
forcing everyone to leave the mounted directory or killing all processes
using it. | grpid default:
not specified | Forces a newly created file in the mounted
file system to inherit the group ID of the parent directory. By
default, a newly created file inherits the effective group ID of
the calling process, unless the GID bit is set on the parent directory.
If the GID bit is set, the new file inherits the group ID of the
parent directory. |
Several NFS mount options allow you to change the length of
time file and directory attributes remain cached on the NFS client.
By default, an NFS client caches certain attributes of files and
directories, like their ownership, size, and modification time.
If a user on an NFS client is making a series of changes to a file,
the changes to the file's attributes are cached and modified
locally on the client, and finally, the resulting attributes are
sent to the server. Table 2-3 NFS Caching Options noac
(default:
not specified) | If
specified, this option prevents the NFS client from caching attributes
for the mounted directory. Specify
noac for a directory
that will be used frequently by many NFS clients. The noac
option ensures that the file and directory attributes on the server
are up to date, because no changes are cached on the clients. However,
if many NFS clients using the same NFS server all disable attribute
caching, the server may become overloaded with attribute requests
and updates. You can also use the actimeo
option to set all the caching timeouts to a small number of seconds,
like 1 or 3.
If you specify noac,
do not specify the other caching options. | nocto
(default:
not specified) | If
specified, this option suppresses fresh attributes when opening
a file. Specify
nocto for a file
or directory that never changes, to decrease the load on your network. | acdirmax=n (default=60) | The
maximum number of seconds a directory's attributes are
cached on the NFS client. When this timeout period expires, the
client flushes its attribute cache, and if the attributes have changed,
the client sends them to the NFS server. For
a directory that rarely changes or that is owned and modified by
only one user, like a user's home directory, you can decrease
the load on your network by setting acdirmax=120
or higher. | acdirmin=n (default=30) | The
minimum number of seconds a directory's attributes are
cached on the NFS client. If the directory is modified before this
timeout expires, the timeout period is extended by acdirmin
seconds. For
a directory that rarely changes or that is owned and modified by
only one user, like a user's home directory, you can decrease
the load on your network by setting acdirmin=60
or higher. | acregmax=n (default=60) | The
maximum number of seconds a file's attributes are cached
on the NFS client. When this timeout period expires, the client
flushes its attribute cache, and if the attributes have changed,
the client sends them to the NFS server. For
a file that rarely changes or that is owned and modified by only
one user, like a file in a user's home directory, you can
decrease the load on your network by setting acregmax=120
or higher. | acregmin=n (default=3) | The
minimum number of seconds a file's attributes are cached
on the NFS client. If the file is modified before this timeout expires,
the timeout period is extended by acregmin
seconds. For
a file that rarely changes or that is owned and modified by only
one user, like a file in a user's home directory, you can
decrease the load on your network by setting acdirmin=30
or higher. | actimeo=n
(no
default) | Setting
actimeo to n
seconds is equivalent to setting acdirmax,
acdirmin, acregmax,
and acregmin
to n
seconds. Set
actimeo=1 or
actimeo=3 for
a directory that is used and modified frequently by many NFS clients.
This ensures that the file and directory attributes are kept reasonably
up to date, even if they are changed frequently from various client
locations. Set actimeo=120
or higher for a directory that rarely or never changes. If
you set the actimeo
value, do not set the acdirmax,
acdirmin, acregmax,
or acregmin values. |
To Ensure Data Integrity
Between the Client and Server |  |
Make sure the directory is exported
from the server with the noasync
option (the default). If the directory is exported with the async
option, the NFS server will acknowledge NFS writes before writing
data to disk. Changing an exported directory from async
to noasync degrades
write performance for that directory. If users or applications will be writing to the
NFS-mounted directory, make sure it is mounted with the hard
option (the default), rather than the soft
option. If you have a small number of NFS applications that
require absolute data integrity, add the O_SYNC
flag to the open()
calls in your applications. When you open a file with the O_SYNC
flag, a write()
call will not return until the write request has been sent to the
NFS server and acknowledged. The O_SYNC
flag degrades write performance for applications that use it. If you have a large number of NFS applications requiring
absolute data integrity, or if your entire installation needs a
high degree of data integrity, set the NUM_NFSIOD
variable to 0 in the /etc/rc.config.d/nfsconf
file on each client, as follows, and issue the following commands to kill all the biod
daemons (PID
is a process ID returned by the ps
command): /usr/bin/ps -ef | /usr/bin/grep biod /usr/bin/kill PID PID ... |
The biod
daemons improve write performance by handling NFS write requests
from users and applications. After a write request is passed to
a biod daemon,
control is returned to the user or application. Running a client
without biod
daemons degrades write performance for all users and applications
on that client. If multiple NFS users will be writing to the same
file, add the lockf()
call to your applications to lock the file so that only one user
may modify it at a time. If multiple users on different NFS clients will be writing
to the file, you must also turn off attribute caching on those clients
by mounting the file with the noac
option.
For more information, see the following man pages: mount(1M),
open(2), write(2),
lockf(2), and
biod(1M). To Remove (Unmount)
a Mounted Directory |  |
On the NFS client, issue the following command to determine
whether the directory you want to unmount is currently in use: /usr/sbin/fuser -cu local_mount_point |
This command lists the process IDs and user names of everyone
using the mounted directory. Warn any users to cd
out of the directory, and kill any processes that are using the
directory, or wait until the processes terminate. You can use the
following command to kill all processes using the mounted directory: /usr/sbin/fuser -ck local_mount_point |
If you want to remove the mounted directory permanently,
use an editor to remove the appropriate line in the /etc/fstab
file. If you want to remove the mounted directory temporarily, leave
the line in /etc/fstab,
and the directory will be mounted again when you reboot your system
or run the NFS startup script. Issue the following command at the HP-UX prompt: /usr/sbin/umount local_mount_point |
If any user or process is using the remote directory, NFS
cannot unmount it and will issue an error message.
For more information, type man 1M mount
or man 1M fuser
at the HP-UX prompt. To Disable NFS Client
Capability |  |
On the NFS client, issue the mount(1M)
command with no options, to get a list of all the mounted file systems
on the client: For every NFS-mounted directory listed by the mount
command, issue 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 everyone
using the mounted directory. Warn any users to cd
out of the directory, and kill any processes that are using the
directory, or wait until the processes terminate. You can use the
following command to kill all processes using the mounted directory: /usr/sbin/fuser -ck local_mount_point |
Issue the following command on the client to unmount
all NFS-mounted directories: Edit the /etc/rc.config.d/nfsconf
file on the client to set the NFS_CLIENT
and AUTOMOUNT
variables to 0. This prevents the client processes from starting
up again when you reboot the client. Issue the following command to disable NFS client
capability: /sbin/init.d/nfs.client stop |
For more information, type man 1M mount
or man 1M fuser
at the HP-UX prompt.
|