Saturday, December 19, 2009

NFS

Network file system is both a protocol and file system for accessing and sharing file systems across a computer network using Linux.
NFS v4 is used in modern Linux distributions. It offers performance improvements, mandates strong security, and introduces a stateful protocol etc.

NFS Server configuration file
/etc/exports – file enumerates the filesystem exported through NFS
share hostname|ipaddress|domain|*(options)

options include
sync                    Reply to requests only after the changes have been committed to stable storage
ro    exports as read-only
rw    reading and writing (default)
no_root_squash    allows normal access by root
noaccess    prevent access
secure    remote access originate from privileged port

To save new changes to export file
# exportfs -a
To remove entries from exports table
# exportfs -u

Export a directory with NFS
To export or share directory called /data
Edit the file /etc/exports, this file serves as the access control list for file systems which may be exported to NFS clients
Add config directive to exports file
/data *(rw,sync)

Restart the nfs service:
# /etc/init.d/nfs restart
or
# service nfs restart

NFS Client configuration
Client computer need to mount file system using mount command or /etc/fstab file
# mkdir /data
# mount -t nfs nfsservername|ip:/mountpoint /data
Add an entry in /etc/fstab
nfsservername|ip:/mountpoint /data nfs defaults 0 0
To list the exported filesytem
# Showmount –e hostname

Mount NFS filesystem in two different directories on same system
NFS Server : nfsserver:/data
Mount to client dirs /data and /backup

Mount command has bind option to remount part of the file hierarchy somewhere else
First mount to /home/data
# mount -t nfs4 nfsserver:/data /data

Now bind /home/data to /backup
# mount --bind /data /backup

NAS (Network attached storage) also supports NFS configuration. Access NAS server using NFS protocol
NFS Daemons, In order to use NFS you need to run portmap service and rpc.statd and rpc.lockd daemons
# chkconfig portmap on
# chkconfig nfslock on
# /etc/init.d/portmap start
# /etc/init.d/nfslock start

To access NAS from client
# mkdir /backup
# mount -o tcp 202.54.20.111:/mountpoint /backup

Add an entry in /etc/fstab
202.54.20.111:/mountpoint /backup nfs defaults 0 0

No comments:

Post a Comment