How To Mount A Remote File System Using Network File System (NFS)
How To Mount A Remote File System Using Network File System (NFS)
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).
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.
If any of these processes is not running, NFS won't work. The status of these processes can
be checked rpcinfo -p command.
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.
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>)
• IP networks — Allows the matching of hosts based on their IP addresses within a larger
network. Example: 192.168.1.0/24
Option
Explanation
secure
This option requires that requests originate on an internet port less than 1024.
insecure
async
Replies to requests before the data is written to disk. This improves performance, but results
in lost data if the server goes down.
sync
rw
ro
no_wdelay
Data is written to the share immediately. This option has no effect if async is also set.
root_squash
Convert incoming requests from user root to the anonymous uid and gid.
no_root_squash
All remote users are mapped as an anonymous user (nfsnobody, with a user id of 65534)
anonuid=userid
anongid=groupid
4) Mount the filesystem from a remote computer using the mount command as shown
below.
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.