How to mount a remote file system using Network File System (NFS)

Network File System or NFS, is a server-client protocol for sharing files between computers on a common network. The NFS server exports one or more directories to the client systems, and the client systems mount one or more of the shared directories to local directories called mount points. After the share is mounted, all I/O operations are written back to the server, and all clients notice the change as if it occurred on the local filesystem. NFS uses RPC for communication.

Network File System (NFS) was originally developed by Sun Microsystems in the mid- 1980s. Linux has support for NFS (both as a client and a server).

Required Packages for Network File System (NFS)

NFS requires two main RPM packages: portmap and nfs-utils. These two packages are installed by default. If you want to confirm it, you can use rpm query command.

The nfs service script starts the following processes:

• rpc.mountd Handles mount requests

• nfsd Starts an nfsd kernel process for each shared directory

• rpc.rquotad Reports disk quota statistics to clients

If any of these processes is not running, NFS won't work. The status of these processes can be checked rpcinfo -p command.

Configuring Network File System(NFS)

1) First step in configuring NFS is to identify the directory, which you are going to export.

In this example, we will create a directory /nfs, and this directory will be exported using NFS.

[root@RHEL05 ~]# mkdir /nfs

2) The second step is to create an entry in /etc/exports file. The NFS configuration file is /etc/exports. Each line in this file lists the directory to be exported, the hosts to which it will be exported, and other options that apply to this export.

A line for an exported file system in /etc/exports has the following structure:

<export_directory> <host_ipaddr>(<export_options>)



The following methods can be used to specify host names:

• single host — Where one particular host is specified with a hostname, or IP address.

• wildcards - Common wildcards * or ? character is used to specify hosts. Example: * specifies all computers within the domain. This also known as globbing.

• IP networks — Allows the matching of hosts based on their IP addresses within a larger network. Example:

• netgroups — Permits an NIS netgroup name.

Important export options




This  option  requires  that  requests  originate  on  an  internet port less than 1024.


 This supports NFS messages above ports 1024.


Replies to requests before the data is written to disk. This improves performance, but results in lost data if the server goes down.


 Data is written upon request. Active by default.


Allow both read and write requests on this NFS volume.


Allow read-only access.


Data is written to the share immediately. This option has no effect if async is also set.


Convert incoming requests from user root to the anonymous uid and gid.


Remote root users get root privileges on the shared directory.


All remote users are mapped as an anonymous user (nfsnobody, with a user id of 65534)


Allows you to map remote users to a specific user ID such as pcguest.


Allows you to map remote groups to a specific group ID such as pcguest.

3) Start the service using ‘service nfs start’ command.

To list the exports, we can use ‘exportfs –v’ command.

4) Mount the filesystem from a remote computer using the mount command as shown below.

[root@RHEL04 ~]# mount -t nfs /nfs

5) After mounting, you can use the remote filesystem locally and once the work is completed, the remote filesystem should be unmounted by using ‘umount’ command.

Related Tutorials