Q. I’m using CentOS 5 Linux 64 bit version. How do I share directory called /data2 to all other UNIX / Linux computers?
A. 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 v4 is used in modern Linux distributions. It offers performance improvements, mandates strong security, and introduces a stateful protocol etc.
How do I export a directory with NFS?
In order to export or share directory called /data2, 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.:
# vi /etc/exports
Add config directive as follows:
/data2 *(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 /data2 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:
# /etc/init.d/nfs restart
NFS client configuration
Client computer need to mount file system using mount command or /etc/fstab file, enter:
# mkdir /mnt/nfs
# mount -t nfs4 nfsserver-name-or-ip:/data2 /mnt/nfs
Read the man page for more configuration options:
$ man exports
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 3 comments… read them below or add one }
Thanks, your steps were so simple and worked for me. The only change I had to do was run this: “mount -t nfs nfsserver-name-or-ip:/data2 /mnt/nfs” in the last step(“nfs” instead of “nfs4″). My Linux was 32-bit platform.
Worked perfectly for me too! THANK YOU
It works but vanishes when the box is restarted? Any way to put /etc/init.d/nfs start in startup script? New to linux.