Linux NFS Server Setup and Configuration With Examples – POFTUT

Linux NFS Server Setup and Configuration With Examples

Network file system is a simple way to share files and folders over the network. NFS is developed by Sun Microsystems in 1980. NFS is very popular in the Linux and Unix world. NFS is an alternative for SMB which is Windows ecosystem file-sharing protocol. We will look at how to install the NFS server, share files and mount shares in this tutorial with some extra configurations.

Install NFS

Installing NFS can be done for Ubuntu, Debian, Kali, Mi

Ubuntu, Debian, Kali, Mint:

Install NFS

Install NFS

Fedora, CentOS, RedHat:

Install NFS

Install NFS

Man

Manpage for NFS daemon or simple server can get like below.

Man

Man

Configuration Files

NFS server works as a daemon as expected. Daemon configuration file is by default in /etc/default/nfs-kernel-server for Ubuntu-based systems

Ubuntu, Debian, Kali, Mint:

Fedora, CentOS, RedHat:

Services

NFS server has more than one service to share files and folders.

Export File

Shares are generally defined in different configuration files than daemon configuration files. NFS shares are called exports and stored into /etc/exports . Below we can see the default export file.

Export files

As we see in this file some examples of shares are defined in comments which have no effect.

Create Share

As stated previously to create share an entry should be created in the export file. We will create a simple entry that does not have advanced attributes. Say our directory we want to share is located at /share .

Put the following line to the /etc/exports

Reload NFS Server

We have to change the configuration of the NFS server and created a new share to enable the new configuration we should reload the server.

LEARN MORE  What Is Linux nfsd Process and Meaning?

Ubuntu, Debian, Kali, Mint:

Reload NFS Server

Reload NFS Server

Fedora,CentOS, RedHat:

Reload NFS Server

Reload NFS Server

List Shares

NFS has the ability to list shares. This feature is similar to SMB. We will run list command from our client named ubu2 . While trying to list share there can be an error like clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host) which simply means a network access error. Generally, firewalls will prevent access to the NFS service to get a share list. Create appropriate rules to access these services.

List NFS Shares

List NFS Shares

Mount NFS Share

NFS shares can be mounted to the local system with regular mount command and NFS related parameters. To mount NFS share NFS file system libraries must be installed which is provided by NFS packages we have previously installed.

Mount NFS Share

Mount NFS Share

  • While mounting shares NFS type provided with -t nfs
  • And remote NFS share specified 192.168.122.179:/share
  • Local mount path is working directory mnt

Unmount NFS

Unmounting is the same as regular disk-based file systems. This will unmount the NFS file system. We will unmount the path /mnt in this example.

Unmount NFS

Unmount NFS

Leave a Reply

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

Enjoy this blog? Please spread the word :)