Mounting:
Automatically Mounting:
After a server exports a directory over the network using NFS, a client computer connects that directory to its own file system using the mount command. That’s the same command used to mount file systems from local hard disks, CDs, and floppies, but with slightly different options.
mount can automatically mount NFS directories added to the /etc/fstabfile, just as it does with local disks. NFS directories can also be added to the /etc/fstabfile in such a way that they are not automatically mounted (so you can mount them manually when you choose). With a noauto option, an NFS directory listed in /etc/fstabis inactive until the mountcommand is used, after the system is up and running, to mount the file system.
To set up an NFS file system to mount automatically each time you start your Linux system, you need to add an entry for that NFS file system to the /etc/fstabfile. That file contains information about all different kinds of mounted (and available to be mounted) file systems for your system. Here’s the format for adding an NFS file system to your local system:
host:directory mountpoint nfs options 0 0
The first item (host:directory) identifies the NFS server computer and shared directory. mountpoint is the local mount point on which the NFS directory is mounted. It’s followed by the file system type (nfs). Any options related to the mount appear next in a comma-separated list. (The last two zeros configure the system to not dump the contents of the file system and not to run fsck on the file system.) The following are examples of NFS entries in /etc/fstab:
maple:/tmp /mnt/maple nfs rsize=8192,wsize=8192 0
oak:/apps /oak/apps nfs noauto,ro 0
In the first example, the remote directory /tmpfrom the computer named maple (maple:/tmp) is mounted on the local directory /mnt/maple(the local directory must already exist). The file system type is nfs, and read (rsize) and write (wsize) buffer sizes (discussed in the “Using mount Options” section later in this chapter) are set at 8192to speed data transfer associated with this connection. In the second example, the remote directory is /appson the computer named oak. It is set up as an NFS file system (nfs) that can be mounted on the /oak/apps directory locally. This file system is not mounted automatically (noauto), however, and can be mounted only as read-only (ro) using the mountcommand after the system is already running.
Manually Mounting an NFS File System:
If you know that the directory from a computer on your network has been exported (that is, made available for mounting), you can mount that directory manually using the mount command. This is a good way to make sure that it is available and working before you set it up to mount permanently. Here is an example of mounting the /tmpdirectory from a computer named maple on your local computer:
# mkdir /mnt/maple
# mount maple:/tmp /mnt/maple
The first command (mkdir) creates the mount point directory (/mnt is a common place to put temporarily mounted disks and NFS file systems). The mountcommand identifies the remote computer and shared file system separated by a colon (maple:/tmp), and the local mount point directory (/mnt/maple) follows.
ENSURE MOUNTING
To ensure that the mount occurred, type mount. This command lists all mounted disks and NFS file systems. Here is an example of the mount command and its output (with file systems not pertinent to this discussion edited out):
# mount
/dev/hda3 on / type ext3 (rw)
..
..
..
maple:/tmp on /mnt/maple type nfs (rw,addr=10.0.0.11)
The output from the mount command shows the mounted disk partitions, special file systems, and NFS file systems. The first output line shows the hard disk (/dev/hda3), mounted on the root file system (/), with read/write permission (rw), with a file system type of ext3 (the standard Linux file system type). The just-mounted NFS file system is the /tmpdirectory from maple (maple:/tmp). It is mounted on /mnt/maple and its mount type is nfs. The file system was mounted read/write (rw), and the IP address of maple is 10.0.0.11(addr=10.0.0.11).
This is a simple example of using mountwith NFS. The mount is temporary and is not remounted when you reboot your computer. You can also add options for NFS mounts:
OPTIONS
-a: Mount all file systems in /etc/fstab(except those indicated as noauto).
-f: This goes through the motions of (fakes) mounting the file systems on the command line (or in /etc/fstab). Used with the -v option, -fis useful for seeing what mount would do before it actually does it.
-r: Mounts the file system as read-only.
-w: Mounts the file system as read/write. (For this to work, the shared file system must have been exported with read/write permission.)
Thursday, February 12, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment