Sun Certified System Administrator for Solaris 10 Study Guide Exams 310-XXX & 310-XXX

Certification Objective 12.02—Working with NFS

Exam Objective 2.3: Explain NFS fundamentals, and configure and manage the NFS server and client including daemons, files, and commands.

The network file system (NFS) is the system that can be used to access file systems over the network. NFS version 4 is the default NFS in Solaris 10. The NFS service is managed by the Service Management Facility covered in Chapter 10. That means NFS can be managed (enabled, disabled, or restarted) by the svcadm command, and the status of NFS service can be obtained by using the svcs command. The issue here is sharing files over the network among computers possibly running different operating systems.

Before learning how to manage NFS, you need to understand the fundamental concepts of NFS.

Understanding NFS

In order to work with the NFS service you need to understand the basic terminology and concepts described in this section.

The NFS Service

The NFS service is a network service that enables computers of different architectures running different operating systems to share file systems across the network. A wide spectrum of operating systems ranging from Windows to Linux/UNIX support NFS. It has become possible to implement the NFS environment on a variety of operating systems because it is defined as an abstract model of a file system, rather than an architectural specification. Each operating system applies the NFS model to its specific file system semantics. This means that file system operations such as reading and writing work for the users as if they were accessing a file on the local system.

The benefits of the NFS service are described here:

NFS is a network service offered in the client/server environment.

NFS Servers and Clients

The NFS is a client/server system. As you learned in Chapter 10, the terms client and server refer to the roles that computers assume in sharing resources (file systems in this case) on the network. In NFS, computers that make their file systems available over the network and thereby offer NFS service to serve the requested files are acting as NFS servers, and the computers that are accessing the file systems are acting as NFS clients. In the NFS framework, a computer on a network can assume the role of a client, a server, or both.

Here is how NFS works:

You can mount an NFS file system automatically with autoFS, which we explore further on in this chapter.

The NFS File Systems

In most UNIX system environments, a file hierarchy that can be shared by using the NFS service corresponds to a file system or a portion of a file system. However, a file system resides on a single operating system, and NFS support works across operating systems. Moreover, the concept of a file system might be meaningless in some non-UNIX environments. Therefore, the term file system in NFS refers to a file or a file hierarchy that can be shared and mounted in the NFS environment.

An NFS server can make a single file or a directory subtree (file hierarchy) available to the NFS service for sharing. A server cannot share a file hierarchy that overlaps with a file hierarchy that is already being shared. Note that peripheral devices such as modems and printers cannot be shared under NFS.

Managing NFS

Since the release of Solaris 9, the NFS server starts automatically when you boot the system. Nevertheless, you do need to manage NFS, which includes administering the NFS service, working with NFS daemons, and making file systems available for sharing.

Administering the NFS Service

When the system is booted, the NFS server is automatically started by executing the nfs.server scripts. However, when the system is up, you may need to stop the service or start it again for whatever reason without rebooting the system. For that, you need to know that the NFS service is managed by the Service Management Facility (SMF) under the identifier network/nfs/server. By means of this identifier, you can find the status of the service by using the svcs command, and you can start (enable) or stop (disable) the service by using the svcadm command.

You can determine whether the NFS service is running on your machine by issuing the command shown here:

svcs network/nfs/server

This command displays whether the NFS service is online or disabled. If you want to stop (disable) the service, issue the following command:

svcadm disable network/nfs/server

You can start the service by issuing the following command:

svcadm enable network/nfs/server

When the system is up, some daemons are running to support the NFS service.

Working with NFS Daemons

Since the release of Solaris 9, NFS service starts automatically when the system is booted. When the system goes into level 3 (or multiuser mode), several NFS daemons are started to support the service. These daemons are listed in Table 12-2.

Table 12-2: Daemons automatically started in NFS version 4 when the system boots

Daemon

Description

automountd

Handles mount and unmount requests from the autofs service.

nfsd

Handles file system requests from clients.

nfs4cbd

Manages the communication endpoints for the NFS version 4 callback program.

nfsmapid

Provides integer-to-String and string-to-integer conversions for the user ID (UID) and the group ID (GID).

The nfsd daemon handles the file system requests from the client and is automatically started with option -a. You can change the parameters of the command by editing the /etc/default/nfs file. The syntax for the nfsd command is as follows:

nfsd [-a] [-c <#_conn>] [-l <listenBacklog>] [-p <protocol>] [-t <device>] [<nservers>]

The options and parameters are described here:

If you want to issue the nfsd command for whatever reason, make sure you stop a previously running nfsd daemon invoked with or without options.

Exam Watch

The default NFS version is version 4 in Solaris 10, Unlike previous versions of NFS, NFS version 4 does not use these daemons: lockd, mountd, nfslogd, and statd.

Before a user can use a file system on a remote computer (server), it needs to be made available for sharing.

Sharing File Systems

On the server machine, you can make a file system available for sharing by using the share command on the machine. You can use this command manually for testing purpose or to make a file system available only until the system is rebooted. If you want to make the sharing of a file system permanent and automatic, you should enter the share command into the /etc/dfs/dfstab file. Each entry of this file is a share command, and this file is automatically executed at boot time when the system enters run level 3. The syntax for the share command is shown here:

share [-F <FSType>] [-o <specificOptions>] [-d <description>] [<pathname>]

The options are described here:

If you want to know the resources being shared on the local server, issue the dfshares command without any arguments or options.

Exam Watch

Remember that two things need to happen on the server before the files can be shared: The share command has been issued or exists in the /etc/dfs/dfstab file, and the nfs server (the server and other daemons) are running.

If you decide to share more file systems permanently when the system is up, perform the following steps:

  1. Add the share commands for the file systems in the /etc/dfs/dsfstab file.

  2. Either reboot the system or issue the shareall command without any options or arguments.

The files related to the NFS service are described in Table 12-3.

Table 12-3: Files related to the NFS service

File Name

Function

/etc/default/autofs

Configuration information for autofs.

/etc/default/fs

Lists the default file system type for local file systems.

/etc/default/nfs

Configuration information for the nfsd daemon.

/etc/dfs/dfstab

Contains a list of local resources to be shared; the share commands.

/etc/mnttab

Lists file systems that are currently mounted.

/etc/dfs/sharetab

Lists the local and remote resources that are shared.

/etc/vfstab

Defines file systems to be mounted locally.

Now that you know how to manage NFS, here are some practical scenarios and their solutions.

SCENARIO & SOLUTION

You are logged on to the server and want to share the nfs file system /usr/libs over the network. What entry would you make into the /etc/dfs/dfstab file so that all the clients have read-only permissions to this directory?

share -F nfs -o ro /usr/libs

How can you make this file system available without rebooting the system?

Issue the following command:

shareall

How can you verify that the NFS service is running on your machine?

Issue the following command:

svcs network/nfs/server

Now you know how the NFS servers share the file systems. But how do the clients access those file systems? They access those file systems the way any Solaris machine accesses any file system—by mounting it. To mount a shared file system on a client machine, you can use the same mount command that you learned in Chapter 5. However, when a network contains a fair number of file systems to share, the manual mounting may not be a very effective way to share the files. To help this situation, Solaris offers the AutoFS facility, which automates mounting.

Категории