Friday, 8 March 2013

Network File System (NFS)

Features:

  • Transparent access to remote  file system.
  • Uses RPC for communication.
To check the nfs package, run the command:
rpm  -qa | grep  -i nfs
rpm  -ql nfs-utils
chkconfig --list nfs
chkconfig --level 35 nfs on

1.  Export a directory on the server using /etc/exports 

/path_to_directory         IP_ADDR (options)

#mkdir /nfs1
#vi /etc/exports
/nfs1     192.168.198.134(rw)
:wq

Start NFS service
#service nfs start

Confirm exports using exportfs -v
#exportfs -v

2. Export /nfs2

#mkdir /nfs2
a.       Create a entry in /etc/exports
b.      Update current exports using exportfs –a


3.  Mount Both exports on a remote system:

mount  -t nfs 192.168.198.136:/nfs1         /nfs1
mount –t nfs 192.168.198.136:/nfs2         /nfs2


4.   Allow Local root user  the ability to write to /nfs1 exports:

#vi /etc/exports
/nfs1     192.168.198.136(rw, no_root_squash)
:wq
exportfs  -a
exportfs  -v


Then on client system,

#umount /nfs1
#mount -t nfs 192.168.198.136:/nfs1       /nfs1
#mount
# cd /nfs1
#seq 1000 >  test.txt

5. Setup mount point so that they are available upon reboot

Client system
a.       #vi /etc/fstab
192.168.198.136:/nfs1            /nfs1     nfs          defaults
192.168.198.136:/nfs2            /nfs2     nfs          defaults

Unmount and confirm that NFS mount points will be available when the client system changes run level.
#umount  /nfs1
#umount  /nfs2
#mount –a
#df -h


6. Attempt to mount /nfs1 and /nfs2 from an unauthorized system:

Mount –t nfs  192.168.198.136:/nfs1 /nfs1
Fails because client IP does not match server /etc/exports
So , update server /etc/exports to allow additional hosts/subnet/etc

/nfs1     192.168.198.0/24(rw,, no_root_squash)
/nfs2     192.168.198.0/24(ro)

exportfs –a to update export table.