{"id":2657,"date":"2016-09-07T15:43:55","date_gmt":"2016-09-07T19:43:55","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2657"},"modified":"2017-12-12T15:59:52","modified_gmt":"2017-12-12T20:59:52","slug":"setup-nfs-server-ubuntu-16","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/","title":{"rendered":"How to set up an NFS server on Ubuntu 16"},"content":{"rendered":"<h1>How to set up an NFS server on Ubuntu 16<\/h1>\n<p>NFS, short for Network File System, is a protocol that allows remote access of files over a network in the same manner that you would access your local file system. It&#8217;s an older protocol, first being developed in 1984, but it&#8217;s been regularly updated and maintained since then, with the latest version, 4.1, coming out in 2010.<\/p>\n<p>This guide will walk you through setting up and mounting an NFS server of your own.<\/p>\n<h2>Getting Started<\/h2>\n<p>To follow the steps in this guide, make sure you have this first:<br \/>\n\u2022 2 servers (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\">Cloud Server<\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\">Dedicated Server<\/a>), each with Ubuntu 16<br \/>\n\u2022 Root access to both machines<\/p>\n<h2>Tutorial<\/h2>\n<p>Here&#8217;s the LAN addresses we&#8217;ll be working with:<br \/>\nServer 1: client &#8211; 10.10.0.134<br \/>\nServer 2: nfs-server &#8211; 10.10.0.135<\/p>\n<p>First we&#8217;ll do some network setup. Edit the hosts file on both servers and add these entries.<\/p>\n<p><code>nano \/etc\/hosts<\/code><\/p>\n<p>code class=&#8221;gris&#8221;>10.0.0.134      client<br \/>\n10.0.0.135      nfs-server<\/code><\/p>\n<p>Let&#8217;s deal with the NFS server first. Install the following package, after making sure the server is fully up to date.<\/p>\n<p><code>apt-get install nfs-kernel-server -y<\/code><\/p>\n<p>Create the shared directory for NFS. This is where you&#8217;ll store the files that you want the client server to access.<\/p>\n<p><code>mkdir \/sharednfs<\/code><\/p>\n<p>Now we can create the exports file. This file identifies which directories you&#8217;ll be sharing. We can add the directory we created in the previous step.<\/p>\n<p><code>nano \/etc\/exports<br \/>\n\/sharednfs 10.0.0.134(rw,sync,no_subtree_check)<\/code><\/p>\n<p>Restart the NFS service so that it loads the export file.<\/p>\n<p><code>systemctl restart nfs-kernel-server.service<br \/>\nexportfs -a<\/code><\/p>\n<p>Let&#8217;s deal with the client server next. Install the NFS package.<\/p>\n<p><code>apt-get install nfs-common -y<\/code><\/p>\n<p>We need to create a shared directory for mounting the nfs server.<\/p>\n<p><code>mkdir \/sharednfs\/<\/code><\/p>\n<p>Now it&#8217;s a simple task to mount the shared directory.<\/p>\n<p><code>mount nfs-server:\/sharednfs \/sharednfs\/<\/code><\/p>\n<p>To explain the NFS addresses we use:<\/p>\n<p><code>nfs-server:\/sharednfs is located on the nfs-server<br \/>\n\/sharednfs is located on the client server<\/code><\/p>\n<p>Double check that the NFS shared directory is indeed mounted.<\/p>\n<p><code>df -h<\/code><\/p>\n<p><code class=\"gris\">root@ubuntu16-client:~# df -h<br \/>\nFilesystem             Size  Used Avail Use% Mounted on<br \/>\nudev                   491M     0  491M   0% \/dev<br \/>\ntmpfs                  100M  3.2M   97M   4% \/run<br \/>\n\/dev\/sda1              9.7G  952M  8.7G  10% \/<br \/>\ntmpfs                  497M     0  497M   0% \/dev\/shm<br \/>\ntmpfs                  5.0M     0  5.0M   0% \/run\/lock<br \/>\ntmpfs                  497M     0  497M   0% \/sys\/fs\/cgroup<br \/>\ntmpfs                  100K     0  100K   0% \/run\/lxcfs\/controllers<br \/>\nnfs-server:\/sharednfs  9.7G  953M  8.7G  10% \/sharednfs  <---------------------- Shared NFS Server\ntmpfs                  100M     0  100M   0% \/run\/user\/0\nroot@ubuntu16-client:~# <\/code><\/p>\n<p>To mount it automatically on boot, add the mount point to the fstab on the client machine.<\/p>\n<p><code>nano \/etc\/fstab<br \/>\nnfs-server:\/sharednfs   \/sharednfs      nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0<\/code><\/p>\n<p>Let's try it out! Go to the NFS server and add a file in the shared directory.<\/p>\n<p><code>cd \/sharednfs<br \/>\ntouch test.txt<\/code><\/p>\n<p>Go to the Client server. Voila, you should see the file that you added on the NFS server.<\/p>\n<p><code>cd \/sharednfs<br \/>\nls<\/code><\/p>\n<p><code class=\"gris\">test.txt<\/code><\/p>\n<h2>Conclusion<\/h2>\n<p>NFS is a versatile protocol with many, many use cases. Now that you know how to set it up, you can experiment to see just how you can incorporate it into your projects. If you found this article helpful, feel free to share it with your friends and let us know in the comments below! <\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>How to set up an NFS server on Ubuntu 16 NFS, short for Network File System, is a protocol that allows remote access of files over a network in the same manner that you would access your local file system. It&#8217;s an older protocol, first being developed in 1984, but it&#8217;s been regularly updated and<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[],"class_list":["post-2657","post","type-post","status-publish","format-standard","hentry","category-applications"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to set up an NFS server on Ubuntu 16 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to set up an NFS server on your Ubuntu 16 server. Read now &amp; Allow remote access of files over your network!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to set up an NFS server on Ubuntu 16 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to set up an NFS server on your Ubuntu 16 server. Read now &amp; Allow remote access of files over your network!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-07T19:43:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-12T20:59:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"963\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/\",\"name\":\"How to set up an NFS server on Ubuntu 16 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"datePublished\":\"2016-09-07T19:43:55+00:00\",\"dateModified\":\"2017-12-12T20:59:52+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to set up an NFS server on your Ubuntu 16 server. Read now & Allow remote access of files over your network!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to set up an NFS server on Ubuntu 16\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to set up an NFS server on Ubuntu 16 - Globo.Tech","description":"This tutorial will show you how to set up an NFS server on your Ubuntu 16 server. Read now & Allow remote access of files over your network!","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:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/","og_locale":"en_US","og_type":"article","og_title":"How to set up an NFS server on Ubuntu 16 - Globo.Tech","og_description":"This tutorial will show you how to set up an NFS server on your Ubuntu 16 server. Read now & Allow remote access of files over your network!","og_url":"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/","og_site_name":"Globo.Tech","article_published_time":"2016-09-07T19:43:55+00:00","article_modified_time":"2017-12-12T20:59:52+00:00","og_image":[{"width":1920,"height":963,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png","type":"image\/png"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/","url":"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/","name":"How to set up an NFS server on Ubuntu 16 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-09-07T19:43:55+00:00","dateModified":"2017-12-12T20:59:52+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to set up an NFS server on your Ubuntu 16 server. Read now & Allow remote access of files over your network!","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/setup-nfs-server-ubuntu-16\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to set up an NFS server on Ubuntu 16"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=2657"}],"version-history":[{"count":5,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2657\/revisions"}],"predecessor-version":[{"id":4010,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2657\/revisions\/4010"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}