How to create NFS Server in Linux


NFS (Network File Server) is used for sharing files between linux to linux, unix to linux and vice versa.

Package: nfs-utils
By Default Port: 2049
Configuration File: /etc/exports

Step 1: Install nfs package

First install nfs-utils package using following command:

# yum -y install nfs-utils

Step 2: Configuration

Edit file idmapd.conf and add the line:

# vi /etc/idmapd.conf
Domain = tecdistro-server

Insert the folder/directory along with network that you want to share it with other unix/linux machines:

# mkdir /data
# chmod a+rwx /data
# vi /etc/exports
/data *(ro)

Step 3: Start Services

Start the services rpcbind, nfslock and nfs.

# service rpcbind start
Starting rpcbind:                         [  OK  ]
# service nfslock start
Starting NFS statd:                       [  OK  ]
# service nfs start
Starting NFS services:                    [  OK  ]
Starting NFS mountd:                      [  OK  ]
Starting NFS daemon:                      [  OK  ]
Starting RPC idmapd:                      [  OK  ]

The following command is equivalent to nfs restart

# exports -ar

Run the services at startup/booting time.

# chkconfig rpcbind on
# chkconfig nfslock on
# chkconfig nfs on

Step 4: On Client Side

Now at the NFS client end, we need to mount that directory in our server to access it locally. To do so, first we need to find out that shares available on the remote server or NFS Server.

# showmount -e

Export list for

Above command shows that a directory named “data” is available at “” to share with your server.
To mount the directory from NFS server to client server use the following command:

# mount /local