{"id":7926,"date":"2021-08-09T09:00:39","date_gmt":"2021-08-09T09:00:39","guid":{"rendered":"https:\/\/green.cloud\/docs\/docly-documentation\/content\/setup-nfs-server-on-linux\/"},"modified":"2026-01-19T00:45:43","modified_gmt":"2026-01-19T00:45:43","slug":"setup-nfs-server-on-linux","status":"publish","type":"docs","link":"https:\/\/green.cloud\/docs\/setup-nfs-server-on-linux\/","title":{"rendered":"How to Setup NFS server on CentOS"},"content":{"rendered":"<h4><strong>What is Linux NFS Server?<\/strong><\/h4>\n<p><strong>Network File Sharing (NFS)<\/strong> is a protocol that allows you to share directories and files with other Linux clients over a network. Shared directories are typically created on a file server, running the NFS server component. Users add files to them, which are then shared with other users who have access to the folder.<\/p>\n<p>An NFS file share is mounted on a client machine, making it available just like folders the user created locally. NFS is particularly useful when disk space is limited and you need to exchange public data between client computers.<\/p>\n<h4><strong>Installing NFS Server<\/strong><\/h4>\n<p>First, we start by installing the necessary packages on the NFS Server. The <strong>nfs-utils<\/strong> package provides a daemon for the NFS server kernel and related tools such as the <strong>showmount<\/strong> program.<\/p>\n<p id=\"H_H3\" data-hs-anchor=\"true\">On CentOS 8:<\/p>\n<p data-hs-anchor=\"true\"><code style=\"font-size: 14px;\">dnf install nfs-utils<\/code><\/p>\n<p data-hs-anchor=\"true\">On CentOS 7:<\/p>\n<p data-hs-anchor=\"true\"><code style=\"font-size: 14px;\">yum -y install nfs-util<\/code><\/p>\n<p data-hs-anchor=\"true\"><span style=\"color: #6b707f; font-size: 16px;\">After successful installation we need to start nfs-server with the following command:<\/span><\/p>\n<p data-hs-anchor=\"true\"><code style=\"font-size: 14px;\">systemctl start nfs-server.service<\/code><\/p>\n<p data-hs-anchor=\"true\"><span style=\"color: #6b707f; font-size: 16px;\">Execute the following command to start nfs-server at the same time as the system:<\/span><\/p>\n<p data-hs-anchor=\"true\"><code style=\"font-size: 14px;\">systemctl enable nfs-server.service<\/code><\/p>\n<p data-hs-anchor=\"true\">Check the status of nfs-server with the following command:<\/p>\n<p data-hs-anchor=\"true\"><code style=\"font-size: 14px;\">systemctl status nfs-server.service<\/code><\/p>\n<p data-hs-anchor=\"true\">The configuration files of the NFS server are:<\/p>\n<p data-hs-anchor=\"true\"><strong>\/etc\/nfs.conf<\/strong>: The main configuration file for the NFS daemon and engine.<br \/>\n<strong>\/etc\/nfsmount.conf<\/strong>: NFS mount configuration file.<br \/>\n<strong>\/etc\/exports<\/strong>: The main config file of NFS, containing the list of files and shared folders on the NFS Server.<br \/>\n<strong>\/etc\/fstab<\/strong>: To automatically mount an NFS directory on the system.<br \/>\n<strong>\/etc\/sysconfig\/nfs<\/strong>: NFS config file to manage rpc listening ports and services.<\/p>\n<p data-hs-anchor=\"true\">Next, we will create files to share on the NFS server. We will create a file <strong>\/mnt\/greencloudvps-test-nfs-server<\/strong> and a file for backup for the root user:<\/p>\n<p data-hs-anchor=\"true\"><code style=\"font-size: 14px;\">mkdir -p \/mnt\/greencloudvps-test-nfs-server<\/code><\/p>\n<p data-hs-anchor=\"true\"><code style=\"font-size: 14px;\">ls -l \/mnt\/<\/code><\/p>\n<p data-hs-anchor=\"true\">Then configure the NFS server <strong>\/etc\/export<\/strong> to determine which clients can access the shared file on the NFS server using the <strong>vi<\/strong> editor.<\/p>\n<p data-hs-anchor=\"true\"><code style=\"font-size: 14px;\">vi \/etc\/export<\/code><\/p>\n<p data-hs-anchor=\"true\">Add this line:<\/p>\n<p data-hs-anchor=\"true\"><code style=\"font-size: 14px;\">\/mnt\/greencloudvps-test-nfs-server  10.0.0.2\/8(rw,sync)<\/code><\/p>\n<p>In there:<\/p>\n<p><strong>\/mnt\/greencloudvps-test-nfs-server<\/strong>: This is the directory to share the data.<br \/>\n<strong>10.0.0.2\/8<\/strong>: The range of accessible addresses.<br \/>\n<strong>(rw,sync)<\/strong>: Access rights.Permissions in NFS:<\/p>\n<p><strong>ro<\/strong>: Read only.<br \/>\n<strong>rw<\/strong>: Read-write.<br \/>\n<strong>noaccess<\/strong>: Denied access.<br \/>\n<strong>root_squash<\/strong>: Prevent remote root users.<br \/>\n<strong>no_root_squash<\/strong>: Allow remote root users.<\/p>\n<p>To export the above file system, we run the <strong>exportfs<\/strong> command with the <strong>-a<\/strong> option to export or unexport all directories, the <strong>-r<\/strong> option to re export all directories, synchronize <strong>\/var\/lib\/nfs \/etab<\/strong> with <strong>\/etc\/export<\/strong> and files in <strong>\/etc\/export.d<\/strong>, and <strong>-v<\/strong> allows the output to be fully displayed.<\/p>\n<p><code style=\"font-size: 14px;\">[root@greencloudvps-net-lab01 ~]# exportfs -arv<br \/>\nexporting 10.0.0.0\/8:\/mnt\/greencloudvps-test-nfs-server<\/code><\/p>\n<p>To display the current export list run the following command:<\/p>\n<p><code style=\"font-size: 14px;\">exportfs -s<\/code><\/p>\n<p>Next, if our system has a <strong>firewall<\/strong>, we need to allow the necessary services through the firewall such as <strong>mountd<\/strong>, <strong>nfs<\/strong>, <strong>rpc-bind<\/strong>:<\/p>\n<p><code style=\"font-size: 14px;\">firewall-cmd --permanent --add-service=nfs<\/code><\/p>\n<p><code style=\"font-size: 14px;\">firewall-cmd --permanent --add-service=rpc-bind<\/code><\/p>\n<p><code style=\"font-size: 14px;\">firewall-cmd --permanent --add-service=mountd<\/code><\/p>\n<p><code style=\"font-size: 14px;\">firewall-cmd --reload<\/code><\/p>\n<h4><strong>Install NFS Client<\/strong><\/h4>\n<p>To be able to use NFS on the Client we need to install the necessary package by executing the following command:<\/p>\n<p>On CentOS 8:<\/p>\n<p><code style=\"font-size: 14px;\">dnf install nfs-utils nfs4-acl-tools<\/code><\/p>\n<p>On CentOS7<\/p>\n<p><code style=\"font-size: 14px;\">yum install nfs-utils nfs4-acl-tools<\/code><\/p>\n<p>To check mount point on NFS Server from client:<\/p>\n<p><code style=\"font-size: 14px;\">[root@greencloudvps-net-lab01 ~]# showmount -e 10.0.0.1<br \/>\nExport list for 10.0.0.1:<br \/>\n\/mnt\/blogd-net-test-nfs-server 10.0.0.2\/8<\/code><\/p>\n<p>Next, we create a local directory <strong>\/mnt\/greencloudvps-test-nfs-client<\/strong> to mount to the NFS Server:<\/p>\n<p><code style=\"font-size: 14px;\">mkdir -p \/mnt\/greencloudvps-test-nfs-client<\/code><\/p>\n<p><code style=\"font-size: 14px;\">ls -l \/mnt\/<\/code><\/p>\n<p>Mount NFS file executes the command below:<\/p>\n<p><code style=\"font-size: 14px;\">mount -t nfs 10.0.0.1:\/mnt\/greencloudvps-test-nfs-server \/mnt\/greencloudvps-test-nfs-client\/<\/code><\/p>\n<p>In there:<\/p>\n<p><strong>10.0.0.1<\/strong>: The address of the NFS server.<br \/>\n<strong>\/mnt\/greencloudvps-test-nfs-server<\/strong>: Shared folder on NFS server.<br \/>\n<strong>\/mnt\/greencloudvps-test-nfs-client\/<\/strong>: Mount point on the NFS client.<\/p>\n<p>Then to confirm the file from the NFS server is mounted by running the mount command and grep nfs.<\/p>\n<p><code style=\"font-size: 14px;\">[root@greencloudvps-lab01 ~]# mount | grep nfs<br \/>\nsunrpc on \/var\/lib\/nfs\/rpc_pipefs type rpc_pipefs (rw,relatime)<br \/>\n10.0.0.1:\/mnt\/greencloudvps-test-nfs-server on \/mnt\/greencloudvps-test-nfs-client type nfs4 (rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.0.0.2,local_lock=none,addr=10.0.0.1)<\/code><\/p>\n<p>To be able to automatically mount to NFS Server when the server starts, we need to edit the <strong>\/etc\/fstab<\/strong> file, adding the following line at the end of the file:<\/p>\n<p><code style=\"font-size: 14px;\">echo \"10.0.0.1:\/mnt\/greencloudvps-test-nfs-server     \/mnt\/greencloudvps-test-nfs-client\/  nfs     defaults 0 0\"&gt;&gt;\/etc\/fstab<\/code><\/p>\n<p>Check the file <strong>\/etc\/fstab<\/strong> after we execute the above command:<\/p>\n<p><code style=\"font-size: 14px;\">cat \/etc\/fstab<\/code><\/p>\n<p>When we want to configure the timeout for the NFS mountpoint in <strong>\/etc\/fstab<\/strong>, the syntax is as follows<\/p>\n<p><code style=\"font-size: 14px;\">:\/Shared folder on NFS server  \/Mount point on NFS client   nfs  soft,timeo=30  0  0<\/code><\/p>\n<p>In there:<\/p>\n<p><strong>timeo<\/strong>: The timeout value.<br \/>\n<strong>30<\/strong>: The time they need to be configured using deciseconds (1 deciseconds equals 1\/10th of a second).<br \/>\n<strong>retrans<\/strong>: How many retries the vehicle will retry in the event of an error.<\/p>\n<p>Note: <strong>timeo<\/strong> and <strong>retrans<\/strong> only work in soft nfs, not in hard nfs.<\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"click-here-to-buy-our-vps\" class=\"elementor-heading-title elementor-size-default\"><strong>Click here to buy our VPS!<\/strong><\/h2>\n<p><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Linux NFS Server? Network File Sharing (NFS) is a protocol that allows you to share directories and files with other Linux clients over a network. Shared directories are typically created on a file server, running the NFS server component. Users add files to them, which are then shared with other users who have [&hellip;]<\/p>\n","protected":false},"author":17,"featured_media":0,"parent":17817,"menu_order":245,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-7926","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Setup NFS server on CentOS - GreenCloud Documentation<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/green.cloud\/docs\/setup-nfs-server-on-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Setup NFS server on CentOS - GreenCloud Documentation\" \/>\n<meta property=\"og:description\" content=\"What is Linux NFS Server? Network File Sharing (NFS) is a protocol that allows you to share directories and files with other Linux clients over a network. Shared directories are typically created on a file server, running the NFS server component. Users add files to them, which are then shared with other users who have [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/green.cloud\/docs\/setup-nfs-server-on-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"GreenCloud Documentation\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-19T00:45:43+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/setup-nfs-server-on-linux\\\/\",\"url\":\"https:\\\/\\\/green.cloud\\\/docs\\\/setup-nfs-server-on-linux\\\/\",\"name\":\"How to Setup NFS server on CentOS - GreenCloud Documentation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/#website\"},\"datePublished\":\"2021-08-09T09:00:39+00:00\",\"dateModified\":\"2026-01-19T00:45:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/setup-nfs-server-on-linux\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/green.cloud\\\/docs\\\/setup-nfs-server-on-linux\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/setup-nfs-server-on-linux\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/green.cloud\\\/docs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GreenCloud Documents\",\"item\":\"https:\\\/\\\/green.cloud\\\/docs\\\/docs\\\/greencloud-documents\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Linux Operating Systems\",\"item\":\"https:\\\/\\\/green.cloud\\\/docs\\\/linux-operating-systems\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to Setup NFS server on CentOS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/green.cloud\\\/docs\\\/#website\",\"url\":\"https:\\\/\\\/green.cloud\\\/docs\\\/\",\"name\":\"GreenCloud Documentation\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/green.cloud\\\/docs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Setup NFS server on CentOS - GreenCloud Documentation","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/green.cloud\/docs\/setup-nfs-server-on-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to Setup NFS server on CentOS - GreenCloud Documentation","og_description":"What is Linux NFS Server? Network File Sharing (NFS) is a protocol that allows you to share directories and files with other Linux clients over a network. Shared directories are typically created on a file server, running the NFS server component. Users add files to them, which are then shared with other users who have [&hellip;]","og_url":"https:\/\/green.cloud\/docs\/setup-nfs-server-on-linux\/","og_site_name":"GreenCloud Documentation","article_modified_time":"2026-01-19T00:45:43+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/green.cloud\/docs\/setup-nfs-server-on-linux\/","url":"https:\/\/green.cloud\/docs\/setup-nfs-server-on-linux\/","name":"How to Setup NFS server on CentOS - GreenCloud Documentation","isPartOf":{"@id":"https:\/\/green.cloud\/docs\/#website"},"datePublished":"2021-08-09T09:00:39+00:00","dateModified":"2026-01-19T00:45:43+00:00","breadcrumb":{"@id":"https:\/\/green.cloud\/docs\/setup-nfs-server-on-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/green.cloud\/docs\/setup-nfs-server-on-linux\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/green.cloud\/docs\/setup-nfs-server-on-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/green.cloud\/docs\/"},{"@type":"ListItem","position":2,"name":"GreenCloud Documents","item":"https:\/\/green.cloud\/docs\/docs\/greencloud-documents\/"},{"@type":"ListItem","position":3,"name":"Linux Operating Systems","item":"https:\/\/green.cloud\/docs\/linux-operating-systems\/"},{"@type":"ListItem","position":4,"name":"How to Setup NFS server on CentOS"}]},{"@type":"WebSite","@id":"https:\/\/green.cloud\/docs\/#website","url":"https:\/\/green.cloud\/docs\/","name":"GreenCloud Documentation","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/green.cloud\/docs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/7926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/comments?post=7926"}],"version-history":[{"count":1,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/7926\/revisions"}],"predecessor-version":[{"id":18295,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/7926\/revisions\/18295"}],"up":[{"embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/docs\/17817"}],"wp:attachment":[{"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/media?parent=7926"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/green.cloud\/docs\/wp-json\/wp\/v2\/doc_tag?post=7926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}