Top Menu

Wednesday, October 3, 2012

Export a directory with NFS


NFS (Network file system) is both a protocol and file system for accessing and sharing file systems across a computer network using UNIX and Linux. NFS Version-4 is used in modern Linux distributions. It offers performance improvements, mandates strong security, and introduces a meaningful protocol etc.
NFS Server configuration
In order to export or share directory called /myshare, you need to edit a file called /etc/exports. The file /etc/exports serves as the access control list for file systems which may be exported to NFS clients.
[root@server01~]# vi /etc/exports
Add config directive as follows:
/myshare *(rw,sync)
Each line contains an export point and a whitespace separated list of clients allowed to mount the file system at that point. Each listed client may be immediately followed by a parenthesized, comma-separated list of export options for that client.
Where,
●rw - Allow both read and write requests on /myshare NFS volume
●sync - Reply to requests only after the changes have been committed to stable storage
Save and close the file. Restart the nfs service
[root@server01~]# /etc/init.d/nfs restart
NFS client configuration
Client computer need to mount file system using mount command or /etc/fstab file, enter.
[root@client01~]# mkdir /mnt/nfs
[root@client01~]# mount -t nfs4 nfsserver-name-or-ip:/myshare /mnt/nfs
Read the man page for more configuration options.
# man exports