How To Start Nfs Service In Linux
NFS (Network File Share) is a protocol that allows you to share directories and files with other Linux clients in a network. The directory to be shared is usually created on the NFS server and files added to it.
The client systems mountain the directory residing on the NFS server, which grants them access to the files created. NFS comes in handy when you need to share common data among client systems especially when they are running out of space.
This guide will comprise 2 chief sections: Installing and configuring NFS Server on Ubuntu eighteen.04/twenty.04 and Installing the NFS customer on the client Linux system.
Installing and configuring NFS Server on Ubuntu
To install and configure the NFS server, follow the steps outlined below.
Step 1: Install NFS Kernel Server in Ubuntu
The first step is to install the nfs-kernel-server package on the server. But before we do this, let'due south offset update the system packages using the post-obit apt control.
$ sudo apt update
One time the update is consummate, proceed and install the nfs-kernel-server package as shown beneath. This will store additional packages such equally nfs-common and rpcbind which are equally crucial to the setup of the file share.
$ sudo apt install nfs-kernel-server
Footstep 2: Create an NFS Consign Directory
The second step will be creating a directory that volition be shared amid client systems. This is too referred to as the export directory and it's in this directory that nosotros shall later create files that will be accessible by client systems.
Run the command below past specifying the NFS mount directory proper name.
$ sudo mkdir -p /mnt/nfs_share
Since nosotros desire all the client machines to access the shared directory, remove any restrictions in the directory permissions.
$ sudo chown -R nobody:nogroup /mnt/nfs_share/
Yous can also tweak the file permissions to your preference. Here's we take given the read, write and execute privileges to all the contents inside the directory.
$ sudo chmod 777 /mnt/nfs_share/
Step 3: Grant NFS Share Admission to Customer Systems
Permissions for accessing the NFS server are defined in the /etc/exports file. And so open the file using your favorite text editor:
$ sudo vim /etc/exports
Y'all tin provide access to a single client, multiple clients, or specify an unabridged subnet.
In this guide, we have immune an entire subnet to have access to the NFS share.
/mnt/nfs_share 192.168.43.0/24(rw,sync,no_subtree_check)
Explanation nigh the options used in the higher up command.
- rw: Stands for Read/Write.
- sync: Requires changes to exist written to the disk before they are applied.
- No_subtree_check: Eliminates subtree checking.
To grant access to a single client, apply the syntax:
/mnt/nfs_share client_IP_1 (re,sync,no_subtree_check)
For multiple clients, specify each customer on a separate file:
/mnt/nfs_share client_IP_1 (re,sync,no_subtree_check) /mnt/nfs_share client_IP_2 (re,sync,no_subtree_check)
Pace 4: Consign the NFS Share Directory
After granting access to the preferred client systems, consign the NFS share directory and restart the NFS kernel server for the changes to come into consequence.
$ sudo exportfs -a $ sudo systemctl restart nfs-kernel-server
Step v: Let NFS Access through the Firewall
For the client to admission the NFS share, y'all demand to allow admission through the firewall otherwise, accessing and mounting the shared directory will be impossible. To achieve this run the command:
$ sudo ufw allow from 192.168.43.0/24 to any port nfs
Reload or enable the firewall (if it was turned off) and check the status of the firewall. Port 2049, which is the default file share, should be opened.
$ sudo ufw enable $ sudo ufw status
Install the NFS Client on the Customer Systems
We're done installing and configuring the NFS service on the Server, allow'due south at present install NFS on the customer system.
Step 1: Install the NFS-Common Bundle
As is the norm, brainstorm by updating the organization packages and repositories before anything else.
$ sudo apt update
Next, install nfs-common packages equally shown.
$ sudo apt install nfs-common
Step 2: Create an NFS Mount Point on Client
Side by side, you need to create a mount point on which you will mount the nfs share from the NFS server. To practise this, run the command:
$ sudo mkdir -p /mnt/nfs_clientshare
Pace three: Mount NFS Share on Client System
The final footstep remaining is mounting the NFS share that is shared by the NFS server. This will enable the client system to access the shared directory.
Let'southward cheque the NFS Server's IP accost using the ifconfig command.
$ ifconfig
To achieve this run the command:
$ sudo mount 192.168.43.234:/mnt/nfs_share /mnt/nfs_clientshare
Step 4: Testing the NFS Share on Client System
To verify that our NFS setup is working, we are going to create a few files in the NFS share directory located in the server.
$ cd /mnt/nfs_share/ $ touch on file1.txt file2.txt file3.txt
Now head back to the NFS customer system and cheque if the files exist.
$ ls -l /mnt/nfs_clientshare/
Great! The output confirms that we can access the files we just created on the NFS server!
And that about it. In this guide, we walked yous through the installation and configuration of the NFS server on Ubuntu 18.04 and Ubuntu 20.04. NFS is rarely used present and has been relegated in favor of the more than robust and secure Samba share protocol.
If You Appreciate What We Do Here On TecMint, Y'all Should Consider:
TecMint is the fastest growing and almost trusted customs site for whatsoever kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, delight consider ownership united states of america a java ( or 2 ) as a token of appreciation.
Nosotros are thankful for your never ending back up.
How To Start Nfs Service In Linux,
Source: https://www.tecmint.com/install-nfs-server-on-ubuntu/
Posted by: kittconew2000.blogspot.com
0 Response to "How To Start Nfs Service In Linux"
Post a Comment