How to configure an NFS Server and NFS Client

NFS (Network File System) is basically developed for sharing of files and folders between Linux/Unix systems by Sun Microsystems in 1980. It allows you to mount your local file systems over a network and remote hosts to interact with them as they are mounted locally on the same system. With the help of NFS, we can set up file sharing between Unix to Linux system and Linuxto Unix system
Benefits of NFS


NFS allows local access to remote files.
It uses standard client/serverarchitecture for file sharing between all *nix based machines.
With NFSit is not necessary that both machines run on the same OS.
With the help of NFSwe can configure centralized storage
Users get their datairrespective of physical location.
No manual refreshneeded for new files.
Newer version of NFSalso supports aclpseudo root mounts.
Can be secured with Firewallsand Kerberos.
 NFS Services
The NFS server package includes three facilities, included in the portmap and nfs-utils packages.
  • portmap: It maps calls made from other machines to the correct RPC service (not required with NFSv4).
  • nfs: It translates remote file sharingrequests into requests on the local file system.
  • mountd: This service is responsible for mountingand unmounting of file systems.
  • /etc/exports: Its a main configuration file of NFS, all exported files and directories are defined in this file at the NFS Server
  • /etc/fstab: To mount a NFS directory on your system across the reboots, we need to make an entry in /etc/fstab………done on the client side è ie if you’re not using autofs (I’ll discuss that later)
  • /etc/sysconfig/nfs: Configuration file of NFS to control on which port rpc and other services are listening.
 Important Files for NFS Configuration
Now to Setup and Configure NFS Mounts on Linux Server
To set this up we will be needing 2 servers at least…
For my tutorial we will be using the below listed servers (ip address is => this is the NFS Server (ip address is       => this is the NFS Client

Installing NFS Server and NFS Client
First NFS Server
On the NFS Server, I will install the following
portmap, nfs-utils*
[root@prometheus.olivermel ~] # yum install nfs* -y
[root@prometheus.olivermel ~] # yum install portmap
Next you want to start the services that came with the above installs
[root@prometheus.olivermel ~] # service nfs start
[root@prometheus.olivermel ~] # service portmap start
[root@prometheus.olivermel ~] # service rpcbind start 
Now we want to make sure these services start upon start up of your machine
[root@prometheus.olivermel ~] # chkconfig nfs on
[root@prometheus.olivermel ~] # chkconfig portmap on
[root@prometheus.olivermel ~] # chkconfig rpcbind on
 You might want to open the following ports…(it wouldn’t hurt)
i.e if you are using the firewall (/etc/sysconfig/iptables) and you don’t want to turn it off

-A INPUT -m state –state NEW -m tcp -p tcp –dport 2049 -j ACCEPT
-A INPUT -m state –state NEW -m udp -p udp –dport 2049 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 111 -j ACCEPT
-A INPUT -m state –state NEW -m udp -p udp –dport 111 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 32803 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 34437 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 892 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 822 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 836 -j ACCEPT
-A INPUT -m state –state NEW -m udp -p udp –dport 836 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 839 -j ACCEPT
-A INPUT -m state –state NEW -m udp -p udp –dport 839 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 819 -j ACCEPT
-A INPUT -m state –state NEW -m udp -p udp –dport 819 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 875 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 662 -j ACCEPT

Do the same for the udp ports
 Next we export the directory we want to make accessible from NFS Server
[root@prometheus.olivermel ~] # mkdir -p /data/linux_lover
[root@prometheus.olivermel ~] # touch /data/linux_lover/testfile.txt
[root@prometheus.olivermel ~] # echo “ i am testing NFS” >> /data/linux_lover/testfile.txt
[root@prometheus.olivermel ~] # vi /etc/exports  => this file contains the items to be exported
Put the below entry on a line
/data/linux_lover,no_root_squash,sync) => I used the name of client here
/data/linux_lover,sync)   => here I used the ip add of perseus
rw = read and write permissions are enabled
sync = The sync option is safest for data, because writes are pushed out to persistent storage before telling the client that the write has finished. The async option results in higher performance but carries increased danger of data corruption, e.g., on power failure
 now load the maps by running the following
[root@prometheus.olivermel ~] # exportfs –a
[root@prometheus.olivermel ~] # service nfs restart
 Now on the NFS Client
Download packages for the services
[root@perseus.olivermel ~} # yum install nfs-utils*
[root@perseus.olivermel ~} # yum install rpcbind
Now, start the services and enable them for start up
[root@perseus.olivermel ~} # service rpcbind start && chkconfig rpcbind on
[root@perseus.olivermel ~} # service nfslock start && chkconfig nfslock on
 Now you can test the exported mount from the server with the following command
[root@perseus.olivermel ~} # mount -t nfs  /mnt
 If this is successful then you should see testfile.txt when you run
[root@perseus.olivermel ~} # ls -l  /mnt
See the following link if you there is an issue and you want to troubleshoot

6 thoughts on “How to configure an NFS Server and NFS Client

  1. I love your blog.. very nice colors & theme. Did you make this website
    yourself or diid you hire someone to do it for you? Plzz respond
    as I’m looking to design my own blog andd would like to find out where u got this from.

  2. Admiring the time and energy you put into your blog and
    detailed information you provide. It’s great to come acrosss a blog every once in a while that isn’t the same out
    of date rehashed material. Excellent read! I’ve saved your
    site and I’m adding your RSS feeds to my Google account.

  3. It’s very straightforward to find out aany matter on net as compared
    to textbooks,as I found this article aat this site.

  4. Terrific work! This is thhe kind of information that should
    be shared across the net. Shame on Google for
    now not positioning thhis post upper! Come
    on over and seek advice from my website . Thanks =)

  5. I’m truly enjoying the design and layout of your blog. It’s a very easy on the eyes which makes it much more enjoyable foor mee to come here
    and visit more often. Didd you hire out a designer to create your theme?
    Superb work!

  6. I blog often and I seriously appreciate your information. Thee article has
    truly peaked my interest.I’m going to book mark your blog and keep checking for new information about once per week.
    I opted in for your Feed as well.

Leave a Reply

Your email address will not be published. Required fields are marked *