Configure (NFS) Linux file sharing server In Linux

NFS (Network File System) is primarily developed for File, folders and data sharing  in Linux and Ubuntu like Operating systems, NFS is distributed file system to provide local access to remote disk and file system. NFS works on Port 2049.

NFS Packages Need to Install

Linux- nfs-utils , nfs-utils-lib, portmap.

Ubuntu- nfs-kernel-server, nfs-common

Installing NFS on Linux & Ubuntu 

Use the following command to install NFS

Linux:  yum -y install nfs-utils , portmap, nfs-utils-lib

Ubuntu: sudo apt-get update,  sudo apt-get install nfs-kernel-server , nfs-common


$sudo dpkg -l nfs-kernel-server (to check if nfs is installed)

$sudo apt-get install nfs-kernel-server (NFS server package)


$sudo apt-get install nfs-common (Client Package)


Configuring NFS

Configuration of NFS is very simple. You just  add the directory  you want to share  to the file/etc/exports.

Create a directory called /tecgeeks with the following command:

 $sudo mkdir /tecgeeks


Next, edit the file /etc/exports:

$sudo  vi /etc/exports

Add the following line  to /etc/exports:

/tecgeeks    192.168.0.0/24 (rw,sync)


Below I have explained above fields :

/tecgeeks--The directory to be shared

192.168.0.0/24 --This network all clients allowed to access the share. You can restrict it by giving one IP address. Or you can use (*) asterisk to share all.

rw--Read and write access

sync--Reply to requests only after any changes have been committed to stable storage.

Start the nfs service on Linux 
#/etc/init.d/nfs start  or #service nfs start

#service rpcbind start

Start the service on Ubuntu

$sudo /etc/init.d/ nfs-kernel-server start


Check the shared files on NFS Client 

Now at the NFS client side, we need to mount that directory  to access it locally. first check if  shared file is available.

$showmount -e 192.168.198.136 (Server IP)


Mount Shared NFS Directory to Local Client System

To mount and to check the shared NFS directory  use following mount command.

$sudo  mount -t nfs 192.168.198.136:/tecgeeks /mnt

$df -h | grep tecgeeks


To mount an NFS directory permanently on your local system  make an entry in “/etc/fstab“.

$sudo  vi /etc/fstab

Add the following new line as shown below.

192.168.198.136:/tecgeeks /mnt nfs defaults 0 0

Some NFS Commands

showmount    -e     :shows the available shares

exportfs  -v     :Displays a list of shares files  and options on a server

exportfs   -a     :Exports all shares listed in  /etc/exports ,or given name

exportfs   -r    :Refresh the server’s list after modifying  /etc/exports
Configure (NFS) Linux file sharing server In Linux Configure (NFS) Linux file sharing server In Linux Reviewed by TecGeeks News on February 17, 2017 Rating: 5

No comments:

Get Your Business Online Now


Powered by Blogger.