Saturday, August 14, 2010

NFS (Network File system) Setup in Linux

Friends, Here is the Quick HOWTO again.. Hope this post is useful for quick reference

Points to Note:
 1. NFS is transparent access to remote file systems
 2. It is Installed by default
 3. Uses RPC for communications

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

Entry something like this,
  a. /path_to_directory     IP_ADDR(rw)  


[example :  /nfs1          192.168.75.110(rw) ]
               
  c. mkdir /nfs1
  d. start NFS server - 'service nfs start'
  e. Confirm export(s) - 'exportfs -v'

Note: NFS matches remote user's UID to local /etc/passwd to determine ACLs

Now login to remote machine and do following.

 3. Mount exports on a remote system
  a. mount -t nfs REMOTE MACHINE IP:SHARE_NAME   LOCAL_MOUNT_POINT


 [ Example:  mount -t nfs 192.168.75.199:/nfs2 /nfs2 ]

 4. Allow local 'root' user the ability to write to /nfs1 export
  a. /etc/exports: (rw,no_root_squash)

 5. Setup mount points so that they're available upon reboot in /etc/fstab


Unmount and confirm that NFS mount points will be available when the client system changes runlevels (reboots, starts, etc.) - 'mount -a'


showmount -a 192.168.75.199 - shows mounts on this system (connected NFS clients)

 6. Attempt to mount /nfs1 from an unauthorized system

  • Fails because client's IP does not match server's /etc/exports
  • Update server's /etc/exports to allow additional hosts/subnet/etc.
  • exportfs -a - to update the export table