{"id":476,"date":"2017-04-29T19:00:30","date_gmt":"2017-04-29T23:00:30","guid":{"rendered":"http:\/\/brian.digitalmaddox.com\/blog\/?p=476"},"modified":"2017-04-29T19:00:30","modified_gmt":"2017-04-29T23:00:30","slug":"creating-a-nas-using-the-raspberry-pi-3-part-3-finally","status":"publish","type":"post","link":"https:\/\/brian.digitalmaddox.com\/blog\/?p=476","title":{"rendered":"Creating a NAS using the Raspberry Pi 3 Part 3 (finally)"},"content":{"rendered":"<p>So I have been meaning to finish up this series for a while now, but other things got in the way (which hopefully I can post on here soon).\u00a0 In the mean time, there are numerous tutorials on-line now about how to set a Pi up as a home file server, so I think I will defer to those instead of wasting more bits on the Internet.\u00a0 However, I would like to point out some things I have done that has resulted in my Pi setup being nice and stable.<\/p>\n<p>This biggest thing to do when using the SD card as the root file system for the Pi is to minimize the number of writes to it.\u00a0 This will help keep it lasting longer and avoid any file system corruption.\u00a0 One thing you can do is modify your \/etc\/fstab and use the <strong>noatime<\/strong> family of attributes.\u00a0 The default of most Pi distributions is ext3\/4, so this should work for you.\u00a0 First find your entry in the \/etc\/fstab for your \/.\u00a0 In mine below, you can see it&#8217;s \/dev\/mmcblk0p2:<\/p>\n<pre>proc \/proc proc defaults 0 0\r\n\/dev\/mmcblk0p2 \/ ext4 defaults 0 1\r\n\/dev\/mmcblk0p1 \/boot\/ vfat defaults 0 2\r\n\/dev\/md0 \/mnt\/filestore xfs defaults,nofail 0 2<\/pre>\n<p>Change line 2 so that it reads like this:<\/p>\n<pre>\/dev\/mmcblk0p2 \/ ext4 defaults,noatime,nodiratime 0<\/pre>\n<p>This will stop the file system from modifying itself each time a directory or file is accessed.<\/p>\n<p>As you can see from my fstab, I also have my RAID partition on the enclosure set to xfs and I use the <strong>nofail<\/strong> attribute.\u00a0 This is very important since your enclosure may not be fully spun up and ready by the time your Pi tries to mount it.\u00a0 If it&#8217;s not there, the Pi will hang (forever in my case since it will cause the kernel to panic).<\/p>\n<p>I also run mariadb and postgresql with postgis on the Pi3, however I have them set to not autostart by running:<\/p>\n<pre>systemctl disable mysqld\r\nsystemctl disable postgresql<\/pre>\n<p>I could leave them running since I&#8217;ve lowered their memory requirements, but choose to only have things running on the Pi 3 whenever I need it to make sure I don&#8217;t run out of memory.<\/p>\n<p>I put their respective data directories on the NAS and then made a soft link under \/var by running;<\/p>\n<pre>ln -s \/mnt\/filestore\/data\/mysql \/var\/lib\/mysql\r\nln -s \/mnt\/filestore\/data\/postgresql \/var\/lib\/postgresql<\/pre>\n<p>You could edit their config files to change the location, but for me I have found it is easier to simply use soft links.\u00a0 Plus, since the servers are not set to start a boot, I do not have to worry about any errors every time the Pi restarts.<\/p>\n<p>I also run recoll on the Pi as I have collected several hundred gigabytes of papers and ebooks over the years.\u00a0 Recoll is a nice utility that provides a semantic search ability.\u00a0 By default, recoll and run your file system and system itself into the ground if you let it.\u00a0 I made a few tweaks so that would play nice whenever I run it periodically on the Pi.\u00a0 The first thing I did was move the ~\/.recoll directory to the NAS and create a soft link by running<\/p>\n<pre>ln -s \/mnt\/filestore\/data recoll .recoll<\/pre>\n<p>Again, the goal is to reduce the number of file system access to the SD card itself.\u00a0 Secondly, I created the .recoll\/recoll.conf file with the following contents:<\/p>\n<pre>topdirs = \/mnt\/filestore\/data\/Documents \/mnt\/filestore\/data\/ebooks \/mnt\/filestore\/data\/Programming\r\nfiltermaxseconds 60\r\nthrQSizes = -1 -1 -1<\/pre>\n<p>The filtermaxseconds parameter tells recoll to stop indexing a file if the filter runs for a whole minute.\u00a0 The thrQSizes option has recoll use a single thread.\u00a0 While this makes it slower, it makes things run much better on the Pi while still allowing other services to run.<\/p>\n<p>If you want to run other services, keep in mind that if they do a lot of I\/O, you should move them to your external drive and use a soft link to redirect like I did above.\u00a0 Doing so will help to greatly extend the life of your SD card and keep you from having to reimage it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I have been meaning to finish up this series for a while now, but other things got in the way (which hopefully I can post on here soon).\u00a0 In the mean time, there are numerous tutorials on-line now about &hellip; <a href=\"https:\/\/brian.digitalmaddox.com\/blog\/?p=476\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-476","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=476"}],"version-history":[{"count":1,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/476\/revisions"}],"predecessor-version":[{"id":477,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/476\/revisions\/477"}],"wp:attachment":[{"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}