{"id":3712,"date":"2023-04-10T07:29:22","date_gmt":"2023-04-10T07:29:22","guid":{"rendered":"https:\/\/geekmungus.co.uk\/?p=3712"},"modified":"2023-04-10T07:31:54","modified_gmt":"2023-04-10T07:31:54","slug":"quick-guide-nfs-server-install-on-ubuntu-linux","status":"publish","type":"post","link":"https:\/\/geekmungus.co.uk\/?p=3712","title":{"rendered":"Quick Guide &#8211; NFS Server Install on Ubuntu Linux"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You can deploy an NFS server onto an Ubuntu Linux server to allow you to provide NFS exports to other machines on your network. The documentation below provides a very quick guide on how to do this.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It assumes you have a Ubuntu Linux 22.04 LTS machine with some storage attached that you want to export to the network for use by other client machines.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"DellME4SeriesStorageforDEEPNFS-InstallNFSServer\">Install NFS Server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Firstly, perform an update of the system.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Install the NFS server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install nfs-kernel-server<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"DellME4SeriesStorageforDEEPNFS-CreateExport\">Create Export<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Make an export directory, in this example we&#8217;ll be creating an export directory called &#8220;export&#8221;. We&#8217;ll then set the owner to a particular user and group, if you not sure what set this to root:root. Then we set the &#8220;sticky bit&#8221; with the chmod command, the Sticky bit is a permission bit that is set on a file\/directory that only lets the owner of the file\/directory or the root user to delete or rename the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir \/mydata\/export\nchown &lt;user>:&lt;group> \/mydata\/export\nchmod 2775 \/mydata\/export<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Edit <strong>\/etc\/exports<\/strong> file. We&#8217;re setting an fsid of 399, this should be unique for every export on this host. This configures the NFS Server with the export it should be providing.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/mydata\/export *(rw,no_subtree_check,no_root_squash,fsid=399)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then apply the settings with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/sbin\/exportfs -r<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Restart the NFS server to take settings and start exporting the export.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart nfs-kernel-server<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"DellME4SeriesStorageforDEEPNFS-ConfigureFirewall\">Configure Firewall<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You might find you can&#8217;t access the NFS server, so we need to configure the firewall to allow NFS through, as we are working with Ubuntu Linux 22.04, we&#8217;ll need to follow these steps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First disable the firewall with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ufw disable<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Before going any further we need to verify that we can mount the export from another machine, so using the section below &#8220;Test Access from Another Machine&#8221; verify you can successfully access the export as you expect; if you can&#8217;t your NFS server isn&#8217;t exporting correctly, or you have some permissions set incorrectly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you can access NFS exports as expected, now run this command to open a firewall port:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw allow from 0.0.0.0\/0 to any port nfs comment 'Allow NFS Access'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Re-enable the firewall:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ufw enable<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"DellME4SeriesStorageforDEEPNFS-TestAccessfromAnotherMachine\">Test Access from Another Machine<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Verify you can access the export from a remote machine.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir \/mnt\/export\nsudo mount nfsserver.domain.com:\/mydata\/export \/mnt\/export<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/unsplash.com\/@viktortalashuk\" data-type=\"URL\" data-id=\"https:\/\/unsplash.com\/@viktortalashuk\">Image Attribution<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can deploy an NFS server onto an Ubuntu Linux server to allow you to provide NFS exports to other machines on your network. The documentation below provides a very quick guide on how to do this. It assumes you have a Ubuntu Linux 22.04 LTS machine with some storage attached that you want to &#8230; <a title=\"Quick Guide &#8211; NFS Server Install on Ubuntu Linux\" class=\"read-more\" href=\"https:\/\/geekmungus.co.uk\/?p=3712\" aria-label=\"Read more about Quick Guide &#8211; NFS Server Install on Ubuntu Linux\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":3715,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-3712","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3712"}],"version-history":[{"count":2,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3712\/revisions"}],"predecessor-version":[{"id":3716,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3712\/revisions\/3716"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/media\/3715"}],"wp:attachment":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}