Different ways to mount the NFS shared directory in Linux?

Mount the NFS shared directory in Linux

In order to access the NFS shared data, we have to mount that shared directory on local mount point. The mounting can be direct mount (manual mount) and indirect mount (auto mount).

Direct mount:

First create the local mount point and then mount that shared NFS directory on our local systems mount point by    # mount <server host name or IP address> : <shared directory with full path><mount point> command. But this is temporary mount and we can mount it permanently by put an entry in /etc/fstab file.

Indirect mount:

This method is used to mount the NFS share by using the Autofs service. Autofs uses the automount daemon to manage our 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 /mnt 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 /product on the remote machine server9.example.com at the mount point /mnt/nfs on your machine, add the following line to auto.master:

/mnt   /etc/auto.misc –timeout 60

Next, add the following line to /etc/auto.misc:

nfs  -rw server9.example.com:/product

The first field in /etc/auto.misc is the name of the /mnt subdirectory. This subdirectory is created dynamically by automount. It should not actually exist on the client machine. The second field contains mount options such asrw for read and write access. The third field is the location of the NFS export including the hostname and directory.

Related Articles:

What is mounting? Types of Mounting in Linux?

Job Automation in Linux.

Mail Server Configuration in Linux.

The directory /mnt must be exits on the local file system. There should be no sub directories on the local file system.

To start the autofs service, at a shell prompt, type the following command:

# servive autofs restart

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

# 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:

# service autofs reload

This is the full information about the NFS Shared Directory. If you have any doubts about this, please let us know.

Leave a Reply

Your email address will not be published. Required fields are marked *