NFS (Network File System)
NFS (Network File System)
Benefits of NFS
NFS Services
Its a System V-launched service. The NFS server package includes three
facilities, included in the portmap and nfs-utils packages.
[root@nfsserver~]#yuminstallnfsutilsnfsutilslib
[root@nfsserver~]#yuminstallportmap(notrequiredwithNFSv4)
[root@nfsserver~]#aptgetinstallnfsutilsnfsutilslib
[root@nfsserver~]#/etc/init.d/portmapstart
[root@nfsserver~]#/etc/init.d/nfsstart
[root@nfsserver~]#chkconfiglevel35portmapon
[root@nfsserver~]#chkconfiglevel35nfson
After installing packages and starting services on both the machines, we need
to configure both the machines for file sharing.
[root@nfsserver~]#mkdir/nfsshare
[root@nfsserver~]#vi/etc/exports
/nfsshare192.168.0.101(rw,sync,no_root_squash)
NFS Options
Some other options we can use in /etc/exports file for file sharing is as
follows.
ro: With the help of this option we can provide read only
access to the shared files i.e client will only be able to read.
[root@nfsclient~]#showmounte192.168.0.100
Exportlistfor192.168.0.100:
/nfsshare192.168.0.101
[root@nfsclient~]#mounttnfs192.168.0.100:/nfsshare/mnt/nfsshare
[root@nfsclient~]#mount|grepnfs
sunrpcon/var/lib/nfs/rpc_pipefstyperpc_pipefs(rw)
nfsdon/proc/fs/nfsdtypenfsd(rw)
192.168.0.100:/nfsshareon/mnttypenfs(rw,addr=192.168.0.100)
The above mount command mounted the nfs shared directory on to nfs
client temporarily, to mount an NFS directory permanently on your system
across the reboots, we need to make an entry in /etc/fstab.
[root@nfsclient~]#vi/etc/fstab
192.168.0.100:/nfsshare/mntnfsdefaults00
I have created a new text file named nfstest.txt in that shared directory.
[root@nfsserver~]#cat>/nfsshare/nfstest.txt
ThisisatestfiletotesttheworkingofNFSserversetup.
[root@nfsclient]#ll/mnt/nfsshare
total4
rwrr1rootroot61Sep2121:44nfstest.txt
root@nfsclient~]#cat/mnt/nfsshare/nfstest.txt
ThisisatestfiletotesttheworkingofNFSserversetup.
root@nfsclient~]#umount/mnt/nfsshare
You can see that the mounts were removed by then looking at the filesystem
again.
[root@nfsclient~]#dfhFnfs
Youll see that those shared directories are not available any more.
machine
showmount -e <server-ip or hostname>: Lists the
name
exportfs -u : Unexports all shares listed in /etc/exports, or given
name
exportfs -r : Refresh the servers list after
modifying /etc/exports
This is it with NFS mounts for now, this was just a start, Ill come up with
more option and features of NFS in our future articles. Till then, Stay
connected with Tecmint.com for more exciting and interesting tutorials in
future. Do leave your comments and suggestions below in the comment
box.