Mounting a Remote File System

Chapter 14, “Managing File Systems,” described how to mount a local file system using the mount command. We’ll use the same mount command to mount a shared file system on a remote host using NFS. Here is the syntax for mounting NFS file systems:

mount -F nfs <options> <-o specific_options > <-O> <server>:<filesystem> <mount_point> 

In this example, server is the name of the NFS server in which the file system is located, filesystem is the name of the shared file system on the NFS server, and mount_point is the name of the local directory that serves as the mount point.

As you can see, this is similar to mounting a local file system. The options are described in Table 22.3.

Table 22.3. NFS mount Command
Option Description
-F <Fstype> Used to specify the FSType on which to operate. The FSType must be specified in /etc/vfstab or by consulting /etc/default/fs or /etc/dfs/fstypes.
-r Mounts the specified file system as read-only.
-m Does not append an entry to the /etc/mnttab table of mounted file systems.
-o <specific_options> specific_options is any of the following options, separated by a comma:
  rw | ro The resource is mounted read/write or readonly. The default is rw.
  suid | nosuid setuid execution is enabled or disabled. The default is suid.
  remount If a file system is mounted as read-only, remounts it as read/write.
  bg | fg If the first attempt to mount the remote file system fails, retries in the background (bg) or in the foreground (fg). The default is fg.
  quota Lets quota check whether the user is over the quota on this file system. If the file system has quotas enabled on the server, quotas still are checked for operations on this file system.
  noquota Prevents quota from checking whether the user exceeded the quota on this file system. If the file system has quotas enabled on the server, quotas still are checked for operations on this file system.
  retry=n The number of times to retry the mount operation. The default is 10000.
  vers=<NFS version number> By default, the version of NFS protocol used between the client and the server is the highest one available on both systems. If the NFS server does not support NFS 3 protocol, the NFS mount uses version 2.
  port=n The server IP port number. The default is NFS_PORT.
  rsize=<n> Sets the read buffer size to <n> bytes. The default value is 32768 if you’re using version 3 of the NFS protocol. The default can be negotiated down if the server prefers a smaller transfer size. If you’re using NFS version 2, the default value is 8192.
  wsize=<n> Sets the write buffer size to <n> bytes. The default value is 32768 if you’re using version 3 of the NFS protocol. The default can be negotiated down if the server prefers a smaller transfer size. If you’re using version 2, the default value is 8192.
  timeo=<n> Sets the NFS timeout to <n> tenths of a second. The default value is 11 tenths of a second for connectionless transports and 600 tenths of a second for connection-oriented transports.
  retrans=<n> Sets the number of NFS retransmissions to <n>; the default value is 5. For connection-oriented transports, this option has no effect because it is assumed that the transport will perform retransmissions on behalf of NFS.
  soft | hard Returns an error if the server does not respond (soft) or continues the retry request until the server responds (hard). If you’re using hard, the system appears to hang until the NFS server responds.The default value is hard.
  intr | nointr Enables or does not enable keyboard interrupts to kill a process that hangs while waiting for a response on a hard-mounted file system.The default is intr, which makes it possible for clients to interrupt applications that might be waiting for an NFS server to respond.
-O The overlay mount lets the file system be mounted over an existing mount point, making the underlying file system inaccessible. If a mount is attempted on a preexisting mount point without this flag being set, the mount fails, producing the error “device busy.”

Here’s a note regarding foreground (fg) and background (bg) mounts: File systems mounted with the bg option indicate that mount is to retry in the background if the server’s mount daemon (mountd) does not respond when, for example, the NFS server is restarted. From the NFS client, mount retries the request up to the count specified in the retry=<n> option. After the file system is mounted, each NFS request made in the kernel waits a specified number of seconds for a response (specified with the timeo=<n> option). If no response arrives, the timeout is multiplied by 2 and the request is retransmitted. If the number of retransmissions has reached the number specified in the retrans=<n> option, a file system mounted with the soft option returns an error, and the file system mounted with the hard option prints a warning message and continues to retry the request.

Sun recommends that file systems mounted as read/write or those containing executable files always be mounted with the hard option. If you use soft-mounted file systems, unexpected I/O errors can occur. For example, consider a write request. If the NFS server goes down, the pending write request simply gives up, resulting in a corrupted file on the remote file system. A read/write file system should always be mounted with the specified hard and intr options. This lets users make their own decisions about killing hung processes. Use the following to mount a file system named /data located on a host named thor with the hard and intr options:

mount -F nfs -o hard,intr thor:/data /data 

If a file system is mounted as hard and the intr option is not specified, the process hangs until the remote file system reappears if the NFS server goes down. For a terminal process, this can be annoying. If intr is specified, sending an interrupt signal to the process kills it. For a terminal process, this can be done by pressing Ctrl+C. For a background process, sending an INT or QUIT signal as follows usually works:

kill -QUIT 3421 

Note

Sending a KILL signal (-9) does not kill a hung NFS process.


To mount a file system called /data, which is located on an NFS server called thor, issue the following command as root from the NFS client:

mount -F nfs -o ro thor:/data /thor_data 

In this case, the /data file system from the server thor is mounted read-only on /thor_data on the local system. Mounting from the command line enables temporary viewing of the file system. If the umount command is issued or the system is restarted, the mount is lost. If you would like this file system to be mounted automatically at every startup, add the following line to the /etc/vfstab file:

thor:/data - /thor_data nfs - yes ro 

Note

The mount and umount commands require root access. The umount command and /etc/vfstab file are described in Chapter 14.


To view resources that can be mounted on the local or remote system, use the dfmounts command, as follows:

dfmounts sparcserver 

The system responds with a list of file systems currently mounted on ultra5:

RESOURCE     SERVER PATHNAME              CLIENTS 
  -          ultra5 /usr                192.168.1.201 
             ultra5 /usr/dt             192.168.1.201 

Sometimes you rely on NFS mount points for critical information. If the NFS server were to go down unexpectedly, you would lose the information contained at that mount point. You can address this issue by using client-side failover. With client-side failover, you specify an alternative file system to use in case the primary file system fails. These file systems should contain equivalent directory structures and identical files. This option is available only on read-only file systems. To set up client-side failover, follow this procedure:

On the NFS client, mount the file system using the -ro option. You can do this from the command line or by adding an entry to the /etc/vfstab file that looks like the following:

zeus,thor:/data  -  /remote_data  nfs  -  no  -o ro 

If multiple file systems are named and the first server in the list is down, failover uses the next alternative server to access files. To mount a replicated set of NFS file systems, which might have different paths to the file system, use the following mount command:

mount -F nfs -o ro zeus:/usr/local/data,thor:/home/data /usr/local/data 

Replication is discussed again in the section that describes Autofs.

Logged file systems were discussed in Chapter 14. This extends that functionality to networked file systems. The daemon nfslogd provides NFS logging and is enabled using the log=<tag> option in the share command, described later. When NFS logging is enabled, all NFS operations on the file system are recorded in a buffer by the kernel. The data recorded includes a timestamp, the client IP address, the UID of the requestor, the file handle of the resource that is being accessed, and the type of operation that occurred. The nfslogd daemon converts this information into ASCII records that are stored in ASCII log files.

Exercise 22.1 Enabling NFS Server Logging

To enable NFS server logging, follow these steps:

1.
As root, share the NFS file system using the following command:

share –F nfs –o ro,log=global <file system name> 

Add this entry to your /etc/dfs/dfstab file if you want it to go into effect every time the server is booted.

The tag used with the log=<tag> option must be entered in /etc/nfs/ nfslog.conf.A global tag identifier is included in /etc/nfs/nfslog.conf. It specifies the default set of values to be used during logging. If no tag identifier is specified when the file system is shared, then the values in the global entry are used. The global values can be modified by updating this entry in /etc/nfs/nfslog.conf. Here is a copy of the default /etc/nfs/ nfslog.conf file:

#ident  "@(#)nfslog.conf        1.5     99/02/21 SMI" 
# 
# Copyright (c) 1999 by Sun Microsystems, Inc. 
# All rights reserved. 
# 
# NFS server log configuration file. 
# 
# <tag> [ defaultdir=<dir_path> ]  
#       [ log=<logfile_path> ] [ fhtable=<table_path> ]  
#       [ buffer=<bufferfile_path> ] [ logformat=basic|extended ] 
# 
global  defaultdir=/var/nfs  
        log=nfslog fhtable=fhtable buffer=nfslog_workbuffer 

In /etc/nfs/nfslog.conf, you can either edit the default settings for all file systems by changing the data associated with the global tag, or you can add a new tag for this file system. If these changes are not needed, you do not need to change this file. The default settings specify that the log files be stored in the /var/nfs directory. Information written to the logs is raw data. The nfslogd daemon converts this raw data into ASCII-readable files.

2.
If the nfslogd daemon is not already running, start it by typing this:

/usr/lib/nfs/nfslogd 

Note

The NFS log files can become very large, so make sure that the /var file system is large enough to hold them or specify an alternate location with adequate disk space.


You can change the file configuration settings in the NFS server logging configuration file called /etc/nfs/nfslog.conf. This file defines the path, filenames, and the type of logging to be used by nfslogd. Each definition is associated with a tag. The global tag defines the default values, but you can create new tags and specify them for each file system you share. The NFS operations to be logged by nfslogd are defined in the /etc/default/nfslogd configuration file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset