2.5. Overview of NFSThe Network File System (NFS) is a distributed filesystem that allows users to mount remote filesystems as if they were local. NFS uses a client/server model in which a server exports directories to be shared, and clients mount the directories to access the files in them. NFS eliminates the need to keep copies of files on several machines by letting the clients all share a single copy of a file on the server. NFS is an RPC-based application-level protocol. For more information on the architecture of network protocols, see Section 2.3 earlier in this chapter. 2.5.1. Administering NFSTo set up NFS clients and servers you must start the NFS daemons on the servers, export filesystems from the NFS servers, and mount the filesystems on the clients. The /etc/exports file is the NFS server configuration file; it controls which files and directories are exported and what kinds of access are allowed. Names and addresses for clients that should be allowed or denied access to NFS are kept in the /etc/hosts.allow and /etc/hosts.deny files. 2.5.2. DaemonsNFS server daemons, called nfsd daemons, run on the server and accept RPC calls from clients. NFS servers also run the mountd daemon to handle mount requests. On the client, caching and buffering are handled by biod, the block I/O daemon. The portmap daemon maps RPC program numbers to the appropriate TCP/IP port numbers. 2.5.3. Exporting FilesystemsTo set up an NFS server, first check that all the hosts that will mount your filesystem can reach your host. Next, edit the /etc/exports file on the server. Each entry in this file indicates the name of a directory to be exported, domain names of machines that will have access to that particular mount point, and any options specific to that machine. A typical entry looks like: /projects hostname1(rw) hostname2(ro) If you are running mountd, the files will be exported as the permissions in /etc/exports allow. See the exports manpage for all available export options. 2.5.4. Mounting FilesystemsTo enable an NFS client, mount a remote filesystem after NFS is started, either by using the mount command or by specifying default remote filesystems in /etc/fstab. For example: # mount servername:/projects /mnt/nfs/projects A mount request calls the server's mountd daemon, which checks the access permissions of the client and returns a pointer to a filesystem. Once a directory is mounted, it remains attached to the local filesystem until it is unmounted with the umount command or until the local system is rebooted. Usually, only a privileged user can mount filesystems with NFS. However, you can enable users to mount and unmount selected filesystems using the mount and umount commands if the user option is set in /etc/fstab. This can reduce traffic by having filesystems mounted only when needed. To enable user mounting, create an entry in /etc/fstab for each filesystem to be mounted. Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|