Search Engine



RedhatEnterpriseLinux Blog

Connecting & Mounting to the NFS Share Folders

Connecting to the NFS Share Folders
There are three ways to mount an NFS export on a client system, assuming the server has given the client permission to do so:
1.     Use the mount command along with the server name, exported directory, and local mount point.
2.     Add the export to /etc/fstab so it is automatically mounted at boot time or is Available to be mounted.
3.     Use the autofs service to mount the share when a user attempts to access it from a client.

1.     Using mount to connect to the NFS Share Folder
If you only need to mount the share occasionally (or if you are testing the export), use the mount command. Create a directory to mount the share, then, as root, execute the following command:
mount -o <options> /mountpoint
replacing the server name, exported directory, and the local mount point. By default, the share is mounted in read-write mode, meaning that all file permissions are retained from the server. It is important to know that the file permissions are based on the user ID and group ID numbers, not the user and group names used on the NFS server. If the client is allowed access by the server, the shared directory will then be available from the specified mount point on the client.
Any NFS mount options can also be used in place of <options> including the following:
. rsize=8192
. wsize=8192
. timeo=14
. intr
The rsize value is the number of bytes used when reading from the server. The wsize value is the number of bytes used when writing to the server. The default for both is 1024, but using 8192 greatly improves throughput and is recommended. The timeo value is the amount of time, in tenths of a second, to wait before resending a transmission after an RPC timeout. After the first timeout, the timeout value is doubled for each retry for a maximum of 60 seconds or until a major timeout occurs. If connecting to a slow server or over a busy network, better performance can be achieved by increasing this timeout value. The intr option allows signals to interrupt the file operation if a major timeout occurs for a hard-mounted share. Refer to the NFS man page with the command man nfs for a full list of available options.

2.     Using /etc/fstab to Connect to the NFS Share
After you have verified that the client can mount the share, you can configure the system to mount it at boot time by modifying the /etc/fstab file as follows:
server:/exported/dir /mountpoint nfs rsize=8192,wsize=8192,timeo=14,intr
Replace the server name, exported directory, and mount point with the appropriate values. The third column indicates that the mount point is of the type nfs.
The last column contains a comma-separated list of NFS options. The options in our example were explained in the previous section, “Using mount to Connect to the NFS Share.”
After the entry is added to /etc/fstab, use the command mount /mountpoint as root to mount the share immediately. Unless the noauto option is specified, it is automatically mounted at boot time.

3.     Using autofs to Connect to the NFS Share
The last option is to use autofs. The autofs service works by using the automount daemon to monitor preconfigured NFS mount points. They are only mounted when a user attempts to access the local mount point directory.
There are several advantages to using autofs instead of configuring shares in /etc/fstab. Because shares are only mounted when they are accessed, system boot time is faster. The system doesn’t have to wait for each NFS server to respond and the mount to succeed. Secondly, it is more secure. Users on the client systems must know what directory is configured to mount the share before changing into that directory to force the mount.
On the other hand, if all shares are mounted on bootup, users can browse the contents of the shared directory if they have permission. If the system is compromised by an unauthorized user, having the shares pre-mounted makes it that much easier for the intruder to find the shared files. Finally, if the clients are configured to use NIS for user authentication, NIS can also be configured to provide the /etc/auto.* files necessary for autofs. So, when a share needs to be added, modified, or removed, the administrator just needs to update the configuration files on the NIS server, and they are populated to all clients after the NIS service is restarted on the clients. The update is almost seamless to the end user.
The master configuration file is /etc/auto.master,  Below shows the default
auto.master file . The master configuration file is /etc/auto.master, List shows the default auto.master file .

LIST Default auto.master File
# $Id: auto.master,v 1.4 2012/01/04 14:36:54 raven Exp $
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
/misc /etc/auto.misc
/net -hosts
# Include central master map if it can be found using
# nsswitch sources.
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
As you can see, the mounts for the /misc/ directory are defined in a different file. One additional configuration file per directory is controlled by autofs. The /misc/ directory in Red Hat Enterprise Linux is reserved for autofs mounts. Because /etc/auto.misc is already created, add NFS mounts to it in the following format:
mountdir <options>
Replace mountdir with the name of the /misc/ subdirectory you want the share to be mounted. For example, to use the directory /misc/data/, replace mountdir with data.
This subdirectory is dynamically created when the share is mounted. Do not create it on the local filesystem.
Replace <options> with a list of comma-separated NFS options discussed previously in this chapter and found in the NFS man page (accessed with the man nfs command). Replace the server name and exported directory as well.
If a directory is used by autofs as a mount point, the directory should not be written to unless the remote filesystem is mounted in that directory. Consider it a reserved directory for autofs.
To start the automount daemon, use the command service autofs start. To stop it, use the command service autofs stop. If the service is already running when the auto.master file or any of the files it includes such as auto.misc is modified, use the command service autofs reload to force a reread of the configuration files. To configure the system to start it at boot time, execute chkconfig autofs on as the root user.


Post a Comment

Powered by Blogger.


Copyright © Redhat Enterprise linux. Original Concept and Design by My Blogger Themes
My name is Abdul Razaq but people call me Raziq. Here is my home page: I live in Quetta, Pakistan and work as an IT-Engineer.