BigAdmin System Administration Portal
Community-Submitted Tech Tips
Print-friendly VersionPrint-friendly Version
This content is submitted by a BigAdmin user. It has not been reviewed for technical accuracy by Sun Microsystems, though it may have been lightly edited to improve readability. If you find an error or would like to comment on the article, please contact the submitter or use the comment field at the bottom of the article. Community submissions may not follow Sun trademark guidelines. For information on Sun trademarks, please see http://www.sun.com/suntrademarks/.
 
 

Introducing NFS Fundamentals for the Solaris OS

Vishal Padwal, August 2008

Network file system (NFS) is a client-server application that lets users view, store, and update files on a remote system as though the files were on a local system.

Note: The information in this tip pertains to the Solaris 9 or 10 Operating System and NFS version 4 (NFSv4), although occasionally NFSv2 and NFSv3 are discussed.

NFS Environment

An NFS environment consists of two components:

  • The NFS server, which contains file resources that are shared with other systems
  • The NFS client, which mounts file resources that are shared over the network and presents the resources as if they were on a local system

NFS Server Files

  • /etc/dfs/dfstab lists the resources to share at boot time.
  • /etc/nfs/nfslogd.conf defines the location of the configuration logs that are used for NFS server logging.
  • /etc/dfs/sharetab lists local resources that are currently being shared by the NFS server.
  • /etc/rmtab lists the file systems remotely mounted by NFS clients. Do not edit this file.
  • /etc/nfs/nfslog.conf lists information defining the location of the configuration logs used for NFS server logging.

Format of dfstab File

# cat /etc/dfs/dfstab
# Place share(1M) commands here for automatic execution
# on entering init state 3.
#
# Issue the command 'svcadm enable network/nfs/server' to
# run the NFS daemon processes and the share commands, after adding
# the very first entry to this file.
#
# share [-F fstype] [-o options] [-d "<text>"] <pathname> [resource]
# .e.g,
# share -F nfs -o rw=engineering -d "home dirs" /export/home2

For example, here we have a home directory called /export/home/<dir_name> that's shared in read-only mode:

share -o ro /export/home/<dir_name>

NFS Server Daemons in the Solaris 10 OS

Description of daemons:

  • mountd handles file system mount requests from remote systems and provides access control. Not used in NFSv4.
  • nfsmapid is the NFS user and group ID mapping daemon, which is used with NFSv4.
  • nfsd handles client file system requests and is used with NFSv4.
  • statd works with the lockd daemon to provide crash recovery and functions for the lock manager.
  • lockd supports record locking operations on NFS files.
  • nfslogd provides operational logging for NFSv2 and v3.

With the Solaris 10 OS and NFSv4, you need only two daemons to support NFS: nfsmapid and nfsd. The mountd and lockd daemons are integrated together, and nfsmapid and nfsd are supported in NFSv4 with port 2049, which improves support for NFS through a firewall.

If you want to use NFSv2 or v3 with the Solaris 10 OS, all daemons are supported.

Starting and Stopping the NFS Server Service

The svc:/network/nfs/server service starts the NFS server daemons when the system enters run level 3.

To start the NFS server daemon manually, run this command:

# svcadm enable svc:/network/nfs/server

To stop the NFS server daemon manually, run this command:

# svcadm disable svc:/network/nfs/server

Checking NFS Dependencies

Check dependencies using the svcs command:

# svcs | grep nfs
# svcs -l nfs/server

NFS Server Commands

  • shareall reads and executes statements from /etc/dfs/dfstab.
  • shares makes a local directory on the NFS server available for mounting.
  • dfshares, when used without any arguments, displays resources currently being shared.
  • dfmount displays a list of NFS server directories that are currently mounted.
  • unshare makes file resources unavailable for mounting.

Configuring the NFS Server for Sharing

Syntax:

# share [-F <FSType>] [-o <option>] [<pathname>]

where:

  • -F <FSType> specifies the file system type.
  • -o <option> specifies the options that control access to the shared resource, for example read-only access.
  • <pathname> specifies the absolute path name of the resource for sharing.

For example, if you want to share the /export/home/<dir_name> directory, make an entry like the following in the /etc/dfs/dfstab file:

#share -F nfs -o ro /export/home/<dir_name>

In this example, -F specifies an NFS file system, -o ro specifies that access to the share is read-only, and /export/home/<dir_name> is the absolute path of the share.

Similarly, by using the -o rw option, you can specify that <pathname> is shared as read/write to all clients, and you can use -o root=<dir_name> to enable root privileges for the <dir_name> directory.

Making File Resources Unavailable for Mounting

Syntax:

# unshare [-F <FSType>] [<pathname>]

For example:

#unshare -F nfs /export/home/<dir_name>

Mounting a Remote File System

Syntax:

mount [-F <FSType>] [-o <options>] <server>:<pathname> [<mount_point>]

For example:

# mount -F nfs -o ro  gladiator:/export/home/<dir_name> /mymountpoint

where:

  • Gladiator is the name of the remote server.
  • /export/home/<dir_name> is the remote file resource.
  • /mymountpoint is the mount point where /export/home/<dir_name> is shared.

Another example:

# mount -o ro Gladiator,Sun,Moon :/Central_data /mymountpoint

In the second example, if the Gladiator system is unavailable, then the request will flow to the second system, which is called Sun, and so on.

Unmounting Remote File Systems From a Client

Syntax:

umount [<mount_point>]

For example:

# umount /mymountpoint

Mounting Remote Resources at Boot Time

To mount a remote file system at boot time, make an entry in /etc/vfstab.

For example, add the following entry in the /etc/dfstab file:

Gladiator:/export/home/<dir_name>  - /mymountpoint nfs - yes bg

where:

  • device to mount is Gladiator:/export/home/<dir_name>
  • device to fsck is -
  • mount point is /mymountpoint
  • FS type is nfs
  • fsck pass is -
  • mount at boot is yes
  • mount options is bg (for background)
The information and links on this page have been provided by a BigAdmin user. The submitter is solely responsible for such information and links. Sun is not responsible for the availability of external sites or resources, and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible or liable, directly or indirectly, for any actual or alleged damage or loss caused by or in connection with use of or reliance on the information posted here, or goods or services available on or through any external site or resource.
 
 

Comments (latest comments first)

Discuss and comment on this resource in the BigAdmin Wiki

Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.


BigAdmin