This post will show you Install and Configure NFS Server on Linux Easily.
If you are interested in learning, Request you to go through the below recommended tutorial.
DevOps Full Course Tutorial for Beginners - DevOps Free Training Online
Docker Full Course Tutorial for Beginners - Docker Free Training Online
Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online
Ansible Full Course Tutorial for Beginners - Ansible Free Training Online
Openstack Full Course Tutorial for Beginners - Openstack Free Training Online
Docker Full Course Tutorial for Beginners - Docker Free Training Online
Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online
Ansible Full Course Tutorial for Beginners - Ansible Free Training Online
Openstack Full Course Tutorial for Beginners - Openstack Free Training Online
Installing and Configuring NFS Server on RHEL7
The main purpose of this article is to explain the below things,
- What is NFS (Network File System)?
- What is required?
- How to Install NFS?
- How to Configure NFS Server?
- How to mount NFS share on client?
What is NFS?
A Network File System (NFS) allows remote hosts to mount file systems over a network and interact with those file systems as though they are mounted locally. This enables system administrators to consolidate resources onto centralized servers on the network.What is Required?
nfs-utils and rpcbind packages at the server end.How to Install NFS Server on Linux?
Install the required packages using YUM as follows, if YUM not configured please visit the link How to Configure Local YUM Repo Server in Linux[root@server1 ~]# yum -y install nfs-utils rpcbind
Before configuring the NFS Server, start and enable the rpcbind and nfs services.
[root@server1 ~]# systemctl start rpcbind
[root@server1 ~]# systemctl start nfs
There are two ways to configure an NFS server:
1. Manually editing the NFS configuration file, that is, /etc/exports, and
2. through the command line, that is, by using the command exportfs.
Editing /etc/exports Configuration File:
The /etc/exports file controls which file systems are exported to remote hosts and specifies options. It follows the following syntax rules:
- Blank lines are ignored.
- To add a comment, start a line with the hash mark (#).
- You can wrap long lines with a backslash ().
- Each exported file system should be on its own individual line.
- Any lists of authorized hosts placed after an exported file system must be separated by space characters.
- Options for each of the hosts must be placed in parentheses directly after the host identifier, without any spaces separating the host and the first parenthesis.
export host(options)
The structure uses the following variables:
export - The directory being exported
host - The host or network to which the export is being shared
options - The options to be used for host
It is possible to specify multiple hosts, along with specific options for each host. To do so, list them on the same line as a space-delimited list, with each hostname followed by its respective options (in parentheses), as in:
export host1(options1) host2(options2) host3(options3)
In our scenario we define two hosts and one share folder /mydata which we use to export to the client:
NFS Server, IP 192.168.2.1
NFS Client, IP 192.168.2.2
At NFS Server End Configuration
Edit the configuration file,
[root@server1 ~]# vi /etc/exports
Add the below list of folders as follows to be exported and file looks like below,
[root@server1 ~]# cat /etc/exports
/mydata *(rw)
Issue the below command to reread to Re-export all NFS directories:
[root@server1 ~]# exportfs -ra
Check the configuration as follows to ensure the newly added settings:
[root@server1 ~]# showmount -e
Export list for server1.learnitguide.net:
/mydata *
[root@server1 ~]#
Server end configuration is done.
At NFS Client End Configuration
Login into the client and verify the nfs shared volumes using the below command.
[root@client1 ~]# showmount -e 192.168.2.1
Export list for server1.learnitguide.net:
/mydata *
[root@client1 ~]#
Mount the NFS volume:
[root@client1 ~]# mount 192.168.2.1:/mydata /mnt/
[root@server1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 7.5G 5.0G 2.6G 67% /
devtmpfs 108M 0 108M 0% /dev
tmpfs 118M 0 118M 0% /dev/shm
tmpfs 118M 8.6M 109M 8% /run
tmpfs 118M 0 118M 0% /sys/fs/cgroup
/dev/sda1 497M 119M 379M 24% /boot
/dev/mapper/VolGroup00-lvol00 4.8G 20M 4.6G 1% /mydata
192.168.2.1:/mydata 4.8G 20M 4.6G 1% /mnt
That's it, we are done with NFS Server configuration at both server and client end.
Related Content on Linux might be useful to you to improve your Linux Skills.
How to Configure IP Address on Ubuntu using Netplan
How to Access Linux Server from Windows Remotely
Configure SSH Passwordless Login Authentication (SSH-keygen)
How to Create LVM Partition in Linux – LVM Tutorial
Install & Configure Samba Server on Linux (RHEL7 / CentOS7)
How to Access Linux Server from Windows Remotely
Configure SSH Passwordless Login Authentication (SSH-keygen)
How to Create LVM Partition in Linux – LVM Tutorial
Install & Configure Samba Server on Linux (RHEL7 / CentOS7)
Keep practicing and have fun. Leave your comments if any.
Support Us: Share with your friends and groups.Stay connected with us on social networking sites, Thank you.
0 Comments