NFS (Network File System)

This section provides a tutorial example on how to setup NFS server and client to share sub-directories as 'nfs' file systems.

If you want to export a local file system to remote computer, you need to install and config NFS (Network File System) server.

Here is what I did on my CentOS 8 computer (IP:

1. Install "nfs-utils" and the required package, "rpcbind":

herong$ sudo dnf install nfs-utils

herong$ sudo dnf install rpcbind

2. Start "nfs-server" and the required service, "rpcbind", using "systemctl" commands. You can also run the server programs directly.

herong$ sudo systemctl start rpcbind

herong$ sudo systemctl start nfs-server

herong$ sudo /etc/init.d/rpcbind start
Starting rpcbind:                                          [  OK  ]

herong$ sudo /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]

3. Check service ports:

herong$ rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100005    1   udp  20048  mountd
    100005    2   tcp  20048  mountd
    100003    3   tcp   2049  nfs
    100021    1   udp  52058  nlockmgr
    100021    1   tcp  46069  nlockmgr

4. Define and control directories to be exported to given IP addresses or IP address ranges.

herong$ sudo vi /etc/exports


5. Refresh NSF server cache.

herong$ sudo systemctl stop nfs-server
herong$ sudo systemctl start nfs-server

herong$ sudo /etc/init.d/nfs stop
herong$ sudo /etc/init.d/nfs start

6. Test on the server locally. It looks good.

herong$ showmount --export

Export list for

7. Open firewall to allow NSF and required services. Since the port numbers are dynamically mapped, I just added the remote computer to the "trusted" zone to accept all ports.

herong$ sudo firewall-cmd --zone=trusted --add-source=

herong$ sudo firewall-cmd --runtime-to-permanent

8. Go to my other Linux computer (IP: Mount the exported sub-directory.

herong$ sudo mkdir /mnt/data
herong$ sudo mount -t nfs /mnt/data

10. Go to the NFS server computer (IP: and verify log messages.

herong$ sudo cat /var/log/messages | grep mount
rpc.mountd[11368]: authenticated mount request from
  for /home/herong/data (/home/herong/data)

If you see the "No such file or directory" error on the client computer, you are trying to mount a NFS file system that is not exported by the server.

herong$ sudo mount -t nfs /mnt/junk

mount.nfs: mounting failed, reason given by server:
  No such file or directory

If you see "Access denied by server while mounting" error on the client computer, your Host name or IP address is not listed in the server's /etc/exports file.

herong$ sudo mount -t nfs /mnt/data

mount.nfs: access denied by server while mounting

If a file on an exported NSF directory is lack of "read" permission for "other", you will get the "Permission denied" error on the remote system even as a "root" user.

You can also use "exportfs" to manage exported NFS file systems.

# Refresh exported NFS file systems
herong$ sudo exportfs -r

# Show exported NFS file systems
herong$ sudo exportfs -s


Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

File Systems

 "df" - Display Free Space of File System

 Mount USB Drive as File System

 "dd" - Copy Data from/to Storage Devices

 Use "dd" Command to Test I/O Speed

 "du" - Display Disk Usage of Directories

 Mount Windows NTFS File System

 Access Persmissions on "ntfs-3g" File System

 Mount Windows Shared Folders

 W95 Ext'd (LBA) Partition

 Reformat NTFS Partition into EXT4 Partition

NFS (Network File System)

 Mount NFS (Network File System) on macOS

 /etc/mtab and /etc/fstab Files

 Unreachable Remote File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Software Package Manager on CentOS - DNF and YUM

 vsftpd - Very Secure FTP Daemon

 Postfix - Mail Transport Agent (MTA)

 Dovecot - IMAP and POP3 Server

 Email Client Tools - Mail User Agents (MUA)

 LDAP (Lightweight Directory Access Protocol)

 Administrative Tasks


 Full Version in PDF/EPUB