{"id":1993,"date":"2018-10-30T17:02:15","date_gmt":"2018-10-30T17:02:15","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=1993"},"modified":"2018-10-31T03:47:19","modified_gmt":"2018-10-31T03:47:19","slug":"papas-got-a-brand-new-nas-the-software","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/30\/papas-got-a-brand-new-nas-the-software\/","title":{"rendered":"Papa&#8217;s Got a Brand New NAS: the Software"},"content":{"rendered":"<p><em>Who needs a custom NAS OS or a web-based GUI when command-line<br \/>\nNAS software is so easy to configure?<\/em><\/p>\n<p>In a recent letter to the editor, I was contacted by a reader who<br \/>\nenjoyed my <a href=\"https:\/\/www.linuxjournal.com\/content\/papas-got-brand-new-nas\">&#8220;Papa&#8217;s<br \/>\nGot a Brand New NAS&#8221;<\/a> article, but wished I had<br \/>\nspent more time describing the software I used. When I<br \/>\nwrote the article, I decided not to dive into the software too much,<br \/>\nbecause it all was pretty standard for serving files under Linux.<br \/>\nBut on second thought, if you want to re-create what I made, I<br \/>\nimagine it would be nice to know the software side as well, so this article<br \/>\ndescribes the software I use in my home NAS.<\/p>\n<h3>The OS<\/h3>\n<p>My NAS uses the <a href=\"https:\/\/www.hardkernel.com\/main\/products\/prdt_info.php\">ODROID-XU4<\/a> as the main computing platform, and so<br \/>\nfar, I&#8217;ve found its octo-core ARM CPU and the rest of its resources<br \/>\nto be adequate for a home NAS. When I first set it up, I visited the<br \/>\n<a href=\"https:\/\/wiki.odroid.com\/odroid-xu4\/odroid-xu4\">official wiki<br \/>\npage<\/a> for the computer, which provides a number of OS<br \/>\nimages, including Ubuntu and Android images that you can copy onto a<br \/>\nmicroSD card. Those images are geared more toward desktop use,<br \/>\nhowever, and I wanted a minimal server image. After some searching,<br \/>\nI found a <a href=\"https:\/\/forum.odroid.com\/viewtopic.php?f=96&amp;t=17542\">minimal image for what was the current Debian stable<br \/>\nrelease at the time (Jessie)<\/a>.<\/p>\n<p>Although this minimal image worked okay for me, I don&#8217;t necessarily<br \/>\nrecommend just going with whatever OS some volunteer on a forum<br \/>\ncreates. Since I first set up the computer, the Armbian project has<br \/>\nbeen released, and it supports a number of standardized OS images for quite<br \/>\na few ARM platforms including the ODROID-XU4. So if you<br \/>\nwant to follow in my footsteps, you may want to start with the <a href=\"https:\/\/www.armbian.com\/odroid-xu4\">minimal Armbian<br \/>\nDebian image<\/a>.<\/p>\n<p>If you&#8217;ve ever used a Raspberry Pi before, the process of setting<br \/>\nup an alternative ARM board shouldn&#8217;t be too different. Use another<br \/>\ncomputer to write an OS image to a microSD card, boot the ARM board,<br \/>\nand at boot, the image will expand to fill the existing filesystem.<br \/>\nThen reboot and connect to the network, so you can log in with the default<br \/>\ncredentials your particular image sets up. Like with Raspbian builds,<br \/>\nthe first step you should perform with Armbian or any other OS image<br \/>\nis to change the default password to something else. Even better,<br \/>\nyou should consider setting up proper user accounts instead of<br \/>\nrelying on the default.<\/p>\n<p>The nice thing about these Debian-based ARM images is that you end<br \/>\nup with a kernel that works with your hardware, but you also have<br \/>\nthe wide variety of software that Debian is known for at your<br \/>\ndisposal. In general, you can treat this custom board like any other<br \/>\nDebian server. I&#8217;ve been using Debian servers for years, and<br \/>\nmany online guides describe how to set up servers under Debian, so<br \/>\nit provides a nice base platform for just about anything you&#8217;d<br \/>\nlike to do with the server.<\/p>\n<p>In my case, since I was migrating to this new NAS from an existing<br \/>\n1U Debian server, including just moving over the physical hard drives<br \/>\nto a new enclosure, the fact that the distribution was the same<br \/>\nmeant that as long as I made sure I installed the same packages on<br \/>\nthis new computer, I could generally just copy over my configuration<br \/>\nfiles wholesale from the old computer. This is one of the big<br \/>\nbenefits to rolling your own NAS off a standard Linux distribution<br \/>\ninstead of using some prepackaged NAS image. The prepackaged solution<br \/>\nmay be easier at first, but if you ever want to migrate off of it<br \/>\nto some other OS, it may be difficult, if not impossible, to take<br \/>\nadvantage of any existing settings. In my situation, even if I had gone<br \/>\nwith another Linux distribution, I still could have copied over all<br \/>\nof my configuration files to the new distribution\u2014in some cases<br \/>\neven into the same exact directories.<\/p>\n<h3>NFS<\/h3>\n<p>As I mentioned, since I was moving from an existing 1U NAS server<br \/>\nbuilt on top of standard Debian services, setting up my NFS service<br \/>\nwas a simple matter of installing the nfs-kernel-server Debian<br \/>\npackage, copying my \/etc\/exports file over from my old server and<br \/>\nrestarting the nfs-kernel-server service with:<\/p>\n<p>$ sudo service nfs-kernel-server restart<\/p>\n<p>If you&#8217;re not familiar with setting up a traditional NFS server<br \/>\nunder Linux, so many different guides exist that I<br \/>\ndoubt I&#8217;d be adding much to the world of NFS documentation<br \/>\nby rehashing it again here. Suffice it to say that it comes down to<br \/>\nadding entries into your \/etc\/exports file that tell the NFS server<br \/>\nwhich directories to share, who to share them with (based on IP)<br \/>\nand what restrictions to use. For instance, here&#8217;s a sample entry I<br \/>\nuse to share a particular backup archive directory with a particular<br \/>\ncomputer on my network:<\/p>\n<p>\/mnt\/storage\/archive 192.168.0.50(fsid=715,rw)<\/p>\n<p>This line tells the NFS server to share the local \/mnt\/storage\/archive<br \/>\ndirectory with the machine that has the IP 192.168.0.50, to give<br \/>\nit read\/write privileges and also to assign this particular share<br \/>\nwith a certain filesystem ID. I&#8217;ve discovered that assigning a<br \/>\nunique fsid value to each entry in \/etc\/exports can help the NFS<br \/>\nserver identify each filesystem it&#8217;s exporting explicitly with<br \/>\nthis ID, in case it can&#8217;t find a UUID for the filesystem (or if you<br \/>\nare exporting multiple directories within the same filesystem).<br \/>\nOnce I make a change to the \/etc\/exports file, I like to tell the<br \/>\nNFS service to reload the file explicitly with:<\/p>\n<p>$ sudo service nfs-kernel-server reload<\/p>\n<p>NFS has a lot of different and complicated options you can apply<br \/>\nto filesystems, and there&#8217;s a bit of an art to tuning things exactly<br \/>\nhow you want them to be (especially if you are deciding between<br \/>\nversion 3 and 4 of the NFS protocol). I typically turn to the exports<br \/>\nman page (type man exports in a terminal) for good descriptions<br \/>\nof all the options and to see configuration examples.<\/p>\n<h3>Samba<\/h3>\n<p>If you just need to share files with Linux clients, NFS may be all<br \/>\nyou need. However, if you have other OSes on your network, or clients<br \/>\nwho don&#8217;t have good NFS support, you may find it useful to<br \/>\noffer Windows-style SMB\/CIFS file sharing using Samba as well. Although Samba<br \/>\nis configured quite differently from NFS, it&#8217;s still not too<br \/>\ncomplicated.<\/p>\n<p>First, install the Samba package for your distribution. In my case,<br \/>\nthat meant:<\/p>\n<p>$ sudo apt install samba<\/p>\n<p>Once the package is installed, you will see that Debian provides a<br \/>\nwell commented \/etc\/samba\/smb.conf file with ordinary defaults set.<br \/>\nI then edited that \/etc\/samba\/smb.conf file and made sure to restrict<br \/>\naccess to my Samba service to only those IPs I wanted to allow by<br \/>\nsetting the following options in the networking section of the<br \/>\nsmb.conf:<\/p>\n<p>hosts allow = 192.168.0.20, 192.168.0.22, 192.168.0.23<br \/>\ninterfaces = 127.0.0.1 192.168.0.1\/24<br \/>\nbind interfaces only = Yes<\/p>\n<p>These changes restrict Samba access to only a few IPs, and explicitly<br \/>\ntell Samba to listen to localhost and a particular interface on the<br \/>\ncorrect IP network.<\/p>\n<p>There are additional ways you can configure access control with<br \/>\nSamba, and by default, Debian sets it up so that Samba uses local<br \/>\nUNIX accounts. This means you can set up local UNIX accounts on the<br \/>\nserver, give them a strong password, and then require that users<br \/>\nauthenticate with the appropriate user name and password before they<br \/>\nhave access to a file share. Because this is already set up in Debian,<br \/>\nall I had left to do was to add some file shares to the end of my<br \/>\nsmb.conf file using the commented examples as a reference. This<br \/>\nexample shows how to share the same \/mnt\/storage\/archive directory<br \/>\nwith Samba instead of NFS:<\/p>\n<p>[archive]<br \/>\npath = \/mnt\/storage\/archive\/<br \/>\nrevalidate = Yes<br \/>\nwriteable = Yes<br \/>\nguest ok = No<br \/>\nforce user = greenfly<\/p>\n<p>As with NFS, there are countless guides on how to configure Samba.<br \/>\nIn addition to those guides, you can do as I do and check out the<br \/>\nheavily commented smb.conf or type man smb.conf if you want more<br \/>\nspecifics on what a particular option does. As with NFS, when you<br \/>\nchange a setting in smb.conf, you need to reload Samba with:<\/p>\n<p>$ sudo service samba reload<\/p>\n<h3>Conclusion<\/h3>\n<p>What&#8217;s refreshing about setting up Linux as a NAS is that file<br \/>\nsharing (in particular, replacing Windows SMB file servers in corporate<br \/>\nenvironments) is one of the first major forays Linux made in the<br \/>\nenterprise. As a result, as you have seen, setting up Linux to be<br \/>\na NAS is pretty straightforward even without some nice GUI. What&#8217;s<br \/>\nmore, since I&#8217;m just using a normal Linux distribution instead of<br \/>\nsome custom NAS-specific OS, I also can use this same server for<br \/>\nall sorts of other things, such as a local DNS resolver, local mail<br \/>\nrelay or any other Linux service I might think of. Plus, down the<br \/>\nroad if I ever feel a need to upgrade, it should be pretty easy to<br \/>\nmove these configurations over to brand new hardware.<\/p>\n<h3>Resources<\/h3>\n<ul>\n<li><a href=\"https:\/\/www.linuxjournal.com\/content\/papas-got-brand-new-nas\">&#8220;Papa&#8217;s<br \/>\nGot a Brand New NAS&#8221;<\/a> by Kyle Rankin, <em>LJ<\/em>, September, 2016<\/li>\n<li><a href=\"https:\/\/www.hardkernel.com\/main\/products\/prdt_info.php\">ODROID-XU4<\/a><\/li>\n<li><a href=\"https:\/\/wiki.odroid.com\/odroid-xu4\/odroid-xu4\">Official Wiki Page for ODROID-XU4<\/a><\/li>\n<li><a href=\"https:\/\/forum.odroid.com\/viewtopic.php?f=96&amp;t=17542\">Original Minimal Jessie Image for Odroid XU4<\/a><\/li>\n<li><a href=\"https:\/\/www.armbian.com\/odroid-xu4\">Armbian Images<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.linuxjournal.com\/content\/papas-got-brand-new-nas-software\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Who needs a custom NAS OS or a web-based GUI when command-line NAS software is so easy to configure? In a recent letter to the editor, I was contacted by a reader who enjoyed my &#8220;Papa&#8217;s Got a Brand New NAS&#8221; article, but wished I had spent more time describing the software I used. When &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/30\/papas-got-a-brand-new-nas-the-software\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Papa&#8217;s Got a Brand New NAS: the Software&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1993","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1993","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=1993"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1993\/revisions"}],"predecessor-version":[{"id":2056,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1993\/revisions\/2056"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=1993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=1993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=1993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}