{"id":17395,"date":"2022-05-30T07:56:21","date_gmt":"2022-05-30T07:56:21","guid":{"rendered":"https:\/\/linuxways.net\/?p=17395"},"modified":"2022-06-02T06:02:39","modified_gmt":"2022-06-02T06:02:39","slug":"how-to-configure-nfs-on-debian","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-configure-nfs-on-debian\/","title":{"rendered":"How to Configure NFS on Debian"},"content":{"rendered":"<p>NFS, also known as Network File System, can be defined as a file machine protocol that enables users to view and access files and directories on a remote system as if they were locally stored. It&#8217;s a client-server architecture, with the server being the system that shares storage and the client being the machine that accesses the server&#8217;s storage. Users and system administrators can mount the complete or a portion of a server&#8217;s file system on a client&#8217;s system using NFS. The mounted files can then be accessed by clients based on the permissions (read, write) that have been assigned to them.<\/p>\n<p>In this article, we will show you how to set up and configure an NFS server and client on a Debian system by running the commands and procedures described below:<\/p>\n<h2>NFS (Network File System) Server<\/h2>\n<p>We&#8217;ll need to install the NFS kernel server on a host machine to share folders. To do so, follow the instructions below:<\/p>\n<h3>Step-1: Installation of the NFS Kernel Server<\/h3>\n<p>Before you start installing the NFS server, make sure your system repository index is up to date by performing the following command in Terminal:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo apt update<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"697\" height=\"181\" class=\"wp-image-17396\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-28.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-28.png 697w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-28-300x78.png 300w\" sizes=\"auto, (max-width: 697px) 100vw, 697px\" \/><\/p>\n<p>Install the NFS Kernel server by using the following command in Terminal once the update is completed.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo apt install nfs-kernel-server rpcbind<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"721\" height=\"428\" class=\"wp-image-17397\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-29.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-29.png 721w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-29-300x178.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/p>\n<p>To confirm the installation with a Y\/n option, press y, and the installation will begin on your computer.<\/p>\n<h3>Step 2: Make a Directory for Exports<\/h3>\n<p>Now we need to make an export directory that can be shared with the client&#8217;s computers. You are free to title it how you see fit. In the \/mnt directory, we&#8217;re creating an export directory called &#8220;sharedfolder.&#8221;<\/p>\n<p>Run the following command, making sure to provide the export directory path:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo mkdir \u2013p \/mnt\/sharedfolder<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"460\" height=\"63\" class=\"wp-image-17398\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical.png\" alt=\"A picture containing text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical.png 460w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical-300x41.png 300w\" sizes=\"auto, (max-width: 460px) 100vw, 460px\" \/><\/p>\n<p>To give all clients access to the export directory, you&#8217;ll need to remove limited permissions. To do so, use the following command:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo chown nobody:nogroup \/mnt\/sharedfolder<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"560\" height=\"61\" class=\"wp-image-17399\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical-1.png\" alt=\"A picture containing text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical-1.png 560w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical-1-300x33.png 300w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/p>\n<p>Then grant everyone access to read, write, and execute new permissions.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo chmod 755 \/mnt\/sharedfolder<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Hence, all clients will be able to access the shared folder available in the mnt directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"471\" height=\"63\" class=\"wp-image-17400\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical-2.png\" alt=\"A picture containing text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical-2.png 471w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical-2-300x40.png 300w\" sizes=\"auto, (max-width: 471px) 100vw, 471px\" \/><\/p>\n<h3>Step-3: Configure the Export Directory<\/h3>\n<p>You can indicate the directories you want to share with your clients, as well as their hostnames, in this section. Run the following command as sudo in Terminal to accomplish the change in the \/etc\/exports file with the nano editor:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo nano \/etc\/exports<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"438\" class=\"wp-image-17401\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-with-low.png\" alt=\"Text Description automatically generated with low confidence\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-with-low.png 733w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-with-low-300x179.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-with-low-501x300.png 501w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/p>\n<p>To grant access to several clients by defining a whole subnet, add the following instruction to the code.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong> \/mnt\/sharedfolder subnetIP\/24(rw,sync,no_subtree_check)<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Customers will have access to our shared directory if they specify the whole subnet.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"435\" class=\"wp-image-17402\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-30.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-30.png 734w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-30-300x178.png 300w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/p>\n<p>Press CTRL+O to save and CTRL+X to leave the \/etc\/exports file once you&#8217;ve finished editing it.<\/p>\n<p>The following permissions are granted to the client via the parameters (rw, sync, no subtree check) in the preceding file:<\/p>\n<ul>\n<li>read and write(rw)<\/li>\n<li>Before implementing any changes, write them to the disk (sync)<\/li>\n<li>no subtree checking<\/li>\n<\/ul>\n<h3>Step 4: Set up the Firewall<\/h3>\n<p>It&#8217;s now crucial to ensure that the server is available for clients to view the shared information. You must add a rule that enables traffic to the NFS port from the specified clients.<\/p>\n<p>If nfw is not installed then you can install it by using the \u201csudo apt install ufw\u201d command. Also if it is not being enabled and is inactive then use the \u201csudo ufw enable\u201d command. But in our case, these things are already being done.<\/p>\n<p>In our case, we&#8217;ll allow the entire 192.168.72.0 network to access the NF port:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo ufw allow from 192.168.72.0\/24 to any port nfs<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"637\" height=\"37\" class=\"wp-image-17403\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/word-image-130.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/word-image-130.png 637w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/word-image-130-300x17.png 300w\" sizes=\"auto, (max-width: 637px) 100vw, 637px\" \/><\/p>\n<p>To check if the rule was correctly added, run the following command in the terminal:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo ufw status<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"119\" class=\"wp-image-17404\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/table-description-automatically-generated.png\" alt=\"Table Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/table-description-automatically-generated.png 621w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/table-description-automatically-generated-300x57.png 300w\" sizes=\"auto, (max-width: 621px) 100vw, 621px\" \/><\/p>\n<p>Our host NFS server is now set up and ready for use by the specified clients.<\/p>\n<h2>Setting Up the Client Machine<\/h2>\n<p>We&#8217;ll now set up the client machine to allow access to the server&#8217;s export directory. To do so, simply follow the steps below:<\/p>\n<h3>Step-1: Install the NFS Client<\/h3>\n<p>To begin, run the following command in Terminal to update your client machine repository index:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo apt update<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"697\" height=\"181\" class=\"wp-image-17405\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-31.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-31.png 697w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-31-300x78.png 300w\" sizes=\"auto, (max-width: 697px) 100vw, 697px\" \/><\/p>\n<p>To accomplish the installation of the NFS client, we used the command:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo apt-get install nfs-common<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"562\" height=\"166\" class=\"wp-image-17406\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-32.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-32.png 562w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/text-description-automatically-generated-32-300x89.png 300w\" sizes=\"auto, (max-width: 562px) 100vw, 562px\" \/><\/p>\n<h3>Step-2: Make a Mount Point<\/h3>\n<p>Make a mount point to access the server&#8217;s shared content. To accomplish this, we used the command:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo mkdir -p \/mnt\/sharedfolder_client<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"70\" class=\"wp-image-17407\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical-3.png\" alt=\"A picture containing text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical-3.png 519w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/a-picture-containing-text-description-automatical-3-300x40.png 300w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/p>\n<h3>Step 3: On the Client, Mount the Directory<\/h3>\n<p>The mount point was established in the previous phase. Now we&#8217;ll mount the shared directory of the NFS server to the previously constructed mount point. To accomplish this, we used the command:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ sudo mount 192.168.72.164:\/mnt\/sharedfolder \/mnt\/sharedfolder_client<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The IP address of our NFS server is 192.168.72.164. On the client&#8217;s PC, the shared NFS directory has been successfully mounted. <img loading=\"lazy\" decoding=\"async\" width=\"724\" height=\"55\" class=\"wp-image-17408\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/word-image-131.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/word-image-131.png 724w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/05\/word-image-131-300x23.png 300w\" sizes=\"auto, (max-width: 724px) 100vw, 724px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>In this article, we have successfully learned about the basic description of NFS and how to install and configure NFS on a Debian Linux system. On a Debian Linux system, this article also discusses how to establish a connection between servers and clients.<\/p>","protected":false},"excerpt":{"rendered":"<p>NFS, also known as Network File System, can be defined as a file machine protocol that enables users to view and access files and directories on a remote&hellip;<\/p>","protected":false},"author":1,"featured_media":17508,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[122,1018],"class_list":["post-17395","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-debian-2","tag-nfs"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/17395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=17395"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/17395\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/17508"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=17395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=17395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=17395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}