Network File System — NFS Installation & Configuration
Last updated on June 5th, 2018 at 02:21 pm
In this tutorial, we will discuss about NFS installation & configuration.
It is used to share a directory between several Linux systems. It allows remote hosts to mount file systems over a network and interact with those file systems as though they are mounted locally on your system.
(Recommended Read: Learn to use Wget command with 12 examples)
To install & test shared folder, we require at least 2 machines :-
- NFS Server
- Client machine to test the mount
OS : Centos/RHEL 6 & 7 OS : Centos/RHEL 6 & 7
Hostname : server.test.com Hostname : client.test.com
IP Address : 192.168.1.100 IP Address : 192.168.1.101
Package Name : nfs-utils, nfs-utils-lib
Main Configuration File : /etc/exports
Firstly we will install NFS, which is easy & can be installed using following command
now, we need to start our server
Now, we will share a directory, lets share our home (/home) directory.
Firstly open configuration file
since its an empty file, we will the following lines to the file to share /home folder
S0, the above line means
/home is directory to be shared,
192.168.1.0/24 will be the subnet range for which shard folder will be available, you can just mention a single IP here,
rw means client will have both read & write permissions. You can also use ro for read only.
Now, restart the service to implement changes to server ,
Our shared folder is now ready to be used.
Note If we are giving rw (read,write) settings on nfs share, make sure the permissions on the folder are 777.
Testing shared folder
On Server, use following command to show shared folder
& on client side, use following command to see the shared folder
Client side configuration
On Client side, we will have to firstly install nfs
we will now mount shared folder to /mnt
so the above command will mount the shared folder, which we can use like a regular partition. But this will only be a temporary mount i.e. when we restart our system, our mount will be lost.
Therfore in order to permanently mount shared folder, we need to make an entry in /etc/fstab
After opening fstab, make the following entry at the bottom of file,
& drive will remain mounted even after system reboot.
Important commands which might come handy,
- showmount -e : Shows the available shares on your local machine
- showmount -e <server-ip or hostname>: Lists the available shares at the remote server
- showmount -d : Lists all the sub directories
- exportfs -a : Exports all shares listed in /etc/exports, or given name
- exportfs -v : Displays a list of shares files and options on a server
- exportfs -r : Refresh the server’s list after modifying /etc/exports
- exportfs -u : Unexports all shares listed in /etc/exports, or given name
So, if you have any questions/comments about this tutorial on NFS installation & configuration, please write them down below. I will surely address them. ADIOS!!!