Network File System (DOC)

Document Sample
Network File System (DOC) Powered By Docstoc
					Network File System (NFS)
Network File System (NFS) is a way to share files between machines on a network as if the files were
located on the client's local hard drive. Red Hat Linux can be both an NFS server and an NFS client,
which means that it can export file systems to other systems and mount file systems exported from
other machines.

Why Use NFS?
NFS is useful for sharing directories of files between multiple users on the same network. For
example, a group of users working on the same project can have access to the files for that project
using a shared directory of the NFS file system (commonly known as an NFS share) mounted in
the directory /myproject. To access the shared files, the user goes into the /myproject directory
on his machine. There are no passwords to enter or special commands to remember. Users work
as if the directory is on their local machines.

Mounting NFS File System
Use the mount command to mount a shared NFS directory from another machine:

             mount /misc/local

Warning: The mount point directory on local machine (/misc/local in the above example) must
In this command, is the hostname of the NFS fileserver, /misc/export is the
directory that shadowman is exporting, and /misc/local is the location to mount the file system on the
local machine. After the mount command runs (and if the client has proper permissions from the NFS server) the client user can execute the command ls /misc/local to
display a listing of the files in /misc/export on

Mounting NFS File Systems using /etc/fstab
An alternate way to mount an NFS share from another machine is to add a line to the /etc/fstab file.
The line must state the hostname of the NFS server, the directory on the server being exported, and
the directory on the local machine where the NFS share is to be mounted. You must be root to modify
the /etc/fstab file.
The general syntax for the line in /etc/fstab is as follows:

             server:/usr/local/pub         /pub    nfs     rsize=8192,wsize=8192,timeo=14,intr

The mount point /pub must exist on the client machine. After adding this line to /etc/fstab on the
client system, type the command mount /pub at a shell prompt, and the mount point /pub will be
mounted from the server.
Mounting NFS File Systems using autofs
A third option for mounting an NFS share is the use of autofs. Autofs uses the automount daemon to
manage your mount points by only mounting them dynamically when they are accessed.
Autofs consults the master map configuration file /etc/auto.master to determine which mount points
are defined. It then starts an automount process with the appropriate parameters for each mount
point. Each line in the master map defines a mount point and a separate map file that defines the file
systems to be mounted under this mount point. For example, the /etc/auto.misc file might define
mount points in the /misc directory; this relationship would be defined in the /etc/auto.master file.
Each entry in auto.master has three fields. The first field is the mount point. The second field is the
location of the map file, and the third field is optional. The third field can contain information such as a
timeout value.
For example, to mount the directory /proj52 on the remote machine at the
mount point /misc/myproject on your machine, add the following line to auto.master:

       /misc    /etc/auto.misc --timeout 60

Add the following line to /etc/auto.misc:

       myproject    -rw,soft,intr,rsize=8192,wsize=8192

The first field in /etc/auto.misc is the name of the /misc subdirectory. This directory is created
dynamically by automount. It should not actually exist on the client machine. The second field
contains mount options such as rw for read and write access. The third field is the location of the NFS
export including the hostname and directory.
Note: The directory /misc must exist on the local file system. There should be no subdirectories in
/misc on the local file system.

Autofs is a service. To start the service, at a shell prompt, type the following commands:

       /sbin/service autofs restart

To view the active mount points, type the following command at a shell prompt:

       /sbin/service autofs status

If you modify the /etc/auto.master configuration file while autofs is running, you must tell the
automount daemon(s) to reload by typing the following command at a shell prompt:

       /sbin/service autofs reload
Command Line Configuration
If you prefer editing configuration files using a text editor or if you do not have the X Window System
installed, you can modify the configuration file directly.
The /etc/exports file controls what directories the NFS server exports. Its format is as follows:

       directory hostname(options)

The only option that needs to be specified is one of sync or async (sync is recommended). If sync is
specified, the server does not reply to requests before the changes made by the request are written
to the disk.
For example:


would allow users from to mount /misc/export with the default read-only
permissions, but:


would allow users from to mount /misc/export with read/write privileges.

Caution: Be careful with spaces in the /etc/exports file. If there are no spaces between the
hostname and the options in parentheses, the options apply only to the hostname. If there is a space
between the hostname and the options, the options apply to the rest of the world. For example,
examine the following lines:

               /misc/export (rw,sync)

The first line grants users from read-write access and denies all other users. The
second line grants users from read-only access (the default) and allows the rest
of the world read-write access.
Each time you change /etc/exports, you must inform the NFS daemon of the change, or reload the
configuration file with the following command:

       /sbin/service nfs reload
Hostname Formats
The host(s) can be in the following forms:
         Single machine — A fully qualified domain name (that can be resolved by the server),
          hostname (that can be resolved by the server), or an IP address
         Series of machines specified with wildscards — Use the * or ? character to specify a string
          match. Wildcards are not to be used with IP addresses; however, they may accidently work
          if reverse DNS lookups fail. When specifying wildcards in fully qualified domain names, dots
          (.) are not included in the wildcard. For example, * includes
          but does not include
         IP networks — Use a.b.c.d/z, where a.b.c.d is the network and z is the number of bits in
          the netmask (for example Another acceptable format is a.b.c.d/netmask,
          where a.b.c.d is the network and netmask is the netmask (for example,

         Netgroups — In the format @group-name, where group-name is the NIS netgroup name.

Starting and Stopping the Server
On the server that is exporting NFS file systems, the nfs service must be running.
View the status of the NFS daemon with the following command:

      /sbin/service nfs status

Start the NFS daemon with the following command:

      /sbin/service nfs start

Stop the NFS daemon with the following command:

      /sbin/service nfs stop

To start the nfs service at boot time, use the command:

      /sbin/chkconfig --level 345 nfs on

You can also use chkconfig, ntsysv or the Services Configuration Tool to configure which services
start at boot time.
The man pages for nfsd, mountd, exports, auto.master, and autofs (in manual sections 5 and 8) —
These man pages show the correct syntax for the NFS and autofs configuration files.

Shared By: