Now we will be creating a directory on host machine which is shared with a client or you can also share already existing directory.
After creating a directory, we need to make or add an entry in "/etc/exports" configuration file and restart the services to make our directory shared on the client system.
In above example, we will be sharing directory /sharenfsdir with client system ip(192.168.3.213) and provided read and write privileges on a shared directory. you can also use HOSTNAME of client machine instead of IP.
To reflect changes from exports config file we need to run below command,
- Restart services on the host machine.
So here we will be completed server or service installation steps.
Configure NFS share directory on Client machine :
Now, we are going to start configuring client machine to access shareable directory.
First we are going to check available shared directory on server for that use below command,
showmount -e 192.168.3.39
Above command shows shared directory /sharenfsdir is available with server ip 192.168.3.39.
To mount that shared directory on client machine we use below mount command,
mount -t nfs 192.168.3.39:/sharenfsdir /mnt/nfsshare [use any path but before mounting on any dir create that directory on system if not available]
with the above help of command we mounted directory on client machine temporarily if you want to make it permanent then add below entry under "/etc/fstab" file.
192.168.3.39:/sharenfsdir /mnt/nfsshare nfs defaults 0 0
Test working of NFS setup :
Create a file under the shared directory on the client machine and checked it on the server it is created or not.
- cd /mnt/nfsshare
- touch nfstestfile.txt
now go on the server and checked under the /sharenfsdir you will found the file under the /sharenfsdir.
To remove NFS mount use below command,
Some important commands for NFS :
- showmount -e : it will shows you available shared directory on server.
- showmount -d : List all the sub directories.
- exportfs -a : it will help to reflect and listed the changes done under the /etc/exports
- exportfs -v : Display's list of share files and options on server.
- exportfs -r : Reflect the changes after modifying /etc/exports
This is all about NFS. I hope you will understand this tutorial if you have any doubts or queries leave your comments and suggestions below in comment box.
Stay connected with Techthings.org for more exciting and interesting posts in future.
Thank you 🙂