System Administration Guide, Volume 3

Automatic File-System Sharing

Servers provide access to their file systems by sharing them over the NFS environment. You specify which file systems are to be shared with the share command or the /etc/dfs/dfstab file.

Entries in the /etc/dfs/dfstab file are shared automatically whenever you start NFS server operation. You should set up automatic sharing if you need to share the same set of file systems on a regular basis. For example, if your computer is a server that supports home directories, you need to make the home directories available at all times. Most file-system sharing should be done automatically; the only time that manual sharing should occur is during testing or troubleshooting.

The dfstab file lists all the file systems that your server shares with its clients and controls which clients can mount a file system. If you want to modify dfstab to add or delete a file system or to modify the way sharing is done, edit the file with any supported text editor (such as vi). The next time the computer enters run level 3, the system reads the updated dfstab to determine which file systems should be shared automatically.

Each line in the dfstab file consists of a share command--the same command you type at the command-line prompt to share the file system. The share command is located in /usr/sbin.

Table 30-1 File-System Sharing Task Map

Task 

Description 

For Instructions, Go to ... 

Establish automatic file-system sharing 

 Steps to configure a server so that file systems are automatically shared when the server is rebooted."How to Set Up Automatic File-System Sharing"

Enable WebNFS 

 Steps to configure a server so that users can access files using WebNFS"How to Enable WebNFS Access"

Enabling NFS server logging 

 Steps to configure a server so that NFS logging is run on selected file systems"How to Enable NFS Server Logging"

How to Set Up Automatic File-System Sharing

  1. Become superuser.

  2. Add entries for each file system to be shared.

    Edit /etc/dfs/dfstab and add one entry to the file for each file system that you want to be automatically shared. Each entry must be on a line by itself in the file and uses this syntax:


    share [-F nfs] [-o specific-options] [-d description] pathname

    See the share_nfs(1M) man page for a complete list of options.

  3. Check that the NFS service is running on the server.

    If this is the first share command or set of share commands that you have initiated, it is likely that the NFS daemons are not running. The following commands kill the daemons and restart them.


    # /etc/init.d/nfs.server stop
    # /etc/init.d/nfs.server start
    

    This ensures that NFS service is now running on the servers and will restart automatically when the server is at run level 3 during boot.

Where to Go From Here

The next step is to set up your autofs maps so that clients can access the file systems you have shared on the server. See "Autofs Administration Task Overview".

How to Enable WebNFS Access

Starting with the 2.6 release, by default all file systems that are available for NFS mounting are automatically available for WebNFS access. The only time that this procedure needs to be followed is on servers that do not already allow NFS mounting, if resetting the public file handle is useful to shorten NFS URLs, or if the -index option is required.

  1. Become superuser.

  2. Add entries for each file system to be shared using the WebNFS service.

    Edit /etc/dfs/dfstab and add one entry to the file for each file system using the -public option. The -index tag shown in the following example is optional.


    share -F nfs -o ro,public,index=index.html /export/ftp

    See the share_nfs(1M) man page for a complete list of options.

  3. Check that the NFS service is running on the server.

    If this is the first share command or set of share commands that you have initiated, it is likely that the NFS daemons are not running. The following commands kill and restart the daemons.


    # /etc/init.d/nfs.server stop
    # /etc/init.d/nfs.server start
    
  4. Share the file system.

    After the entry is in /etc/dfs/dfstab, the file system can be shared by either rebooting the system or by using the shareall command. If the NFS daemons were restarted in step 2, this command does not need to be run because the script runs the command.


    # shareall
    
  5. Verify that the information is correct.

    Run the share command to check that the correct options are listed:


    # share
    -        /export/share/man   ro   ""
    -        /usr/src     rw=eng   ""
    -        /export/ftp    ro,public,index=index.html  ""

How to Enable NFS Server Logging

  1. Become superuser.

  2. Optional: Change file system configuration settings.

    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 format of /etc/nfs/nfslog.conf is described in nfslog.conf(1).

  3. Add entries for each file system to be shared using NFS server logging.

    Edit /etc/dfs/dfstab and add one entry to the file for the file system that you want to have NFS server logging enabled on. The tag used with the log=tag option must be entered in /etc/nfs/nfslog.conf. This example uses the default settings in the global tag.


    share -F nfs -o ro,log=global /export/ftp

    See the share_nfs(1M) man page for a complete list of options.

  4. Check that the NFS service is running on the server.

    If this is the first share command or set of share commands that you have initiated, it is likely that the NFS daemons are not running. The following commands kill and restart the daemons.


    # /etc/init.d/nfs.server stop
    # /etc/init.d/nfs.server start
    
  5. Share the file system.

    After the entry is in /etc/dfs/dfstab, the file system can be shared by either rebooting the system or by using the shareall command. If the NFS daemons were restarted earlier, this command does not need to be run because the script runs the command.


    # shareall
    
  6. Verify that the information is correct.

    Run the share command to check that the correct options are listed:


    # share
    -        /export/share/man   ro   ""
    -        /usr/src     rw=eng   ""
    -        /export/ftp    ro,log=global  ""
  7. Start the NFS log daemon, nfslogd, if it is not running already.

    Restarting the NFS daemons using the nfs.server script will start the daemon if the nfslog.conf file exists. Otherwise the command needs to be run once by hand to create the files so that the command will automatically restart when the server is rebooted.


    # /usr/lib/nfs/nfslogd