How to install and configure NFS Server
In this tutorial we will learn how to install and configure NFS server. Network File System (NFS) is basically developed for sharing folders and files between linux/unix systems. NFS is a server-client protocol used for sharing files between *nix systems. NFS enables you to mount a remote share locally.
Server Side Configuration
We can install nfs by using command yum install nfs* (* is used for all) as shown in below image;
After installation we can start nfs service by using below command;
Systemctl start nfs (we can also use status/restart/reload/stop option)
Lets start configuring the NFS share. we will use create folder ‘share.folder’ under / (root) directory. we will then
use this folder as shared
For tutorial purpose I have put one folder share and text file
To enable above folder to be shared we will edit file /etc/exports file
Define the path with folder name and here I am using * for any network .You can specify network or specific IP for particular sharing. (Note: you can write 192.168.0.0/24 for whole network)
Above example configuration allows the client server to both read and write access within the share.folder. You can use ro (read only) access. no_root_squash (turn off root. This option is mainly useful for diskless clients).
To check shared directory use exportfs command on server.
Setting up the NFS client at Client machine
Install nfs-utils at client side by using yum install nfs-utils command press y to begin installation;
Start service of nfs here I am using CentOS 6.5 in this version you can start service through service nfs start (Note: you can also use stop/restart/status/reload).
For checking the shared directory/folder we can use showmount –e (server IP/hostname)
We can mount that folder by using mount –t nfs 192.168.40.123:/share.folder /mnt/ (here I am going to mount folder in mnt directory) and hit enter; (Note: this is temporary mount after reboot we are not able to use mount/sharing folder)
now list content of .mnt directory using ll command
we have added line at bottom of file to mount share.folder permanently
192.168.40.123:/share.folder /mnt/ nfs default 0 0
Removing the nfs mount we can use umount /mnt/
If anyone faces any issue regarding NFS server feel free to contact us. 🙂