Mounting an NAS on RPi with NSF

I am NOT really a slow learner! The reason I am so defensive: It has taken me a little better than three weeks to establish file connections across my LAN to four of the five public volumes on a brand-new Synology DS218+ NAS.

I did OK in high school, graduated magna cum laude in under-grad and earned an MBA in finance from a major state University while working full time.  At one point I was the only person in a Fortune 500 company who was NOT in IT, but was designated an IT resource. No kidding, I really am not, at least usually, a slow learner.

Along the way I have read many dozens of articles and recipes on how to do this-that-and-something-else; virtually all of which did not work. I estimate I tried over 140 different lines of commands, some several times, before one finally clicked.  I spent — make that wasted — at least 2 week on cifs, ntsf, smb and samba.

OK, to be fair, I had a ten-year-old Cisco NAS with standard grade hard drives that started to fail FAST during the process, and my efforts got interrupted long enough for me to purchase and install the Synology with a pair of Seacrest IronWolf NAS grade 4TB hard drives.  Just before it’s last dying rotation, I actually managed to connect my RPi to the Cisco unit briefly with the following command:
sudo mount -cifs //MyNas/Disk\1 /nbt/nas -o username=mypiname,password=mypwd,domain=MYWORKGROUP

There was a bit more to it, but I don’t want to encourage you to waste your time on this path.

The answer is: use NFS.  NFS works great, but the devil is in the details and there are several things other than just the mount command that you have to pay attention to for it to work. Read on for all I can remember.

JOB ONE:   After setting up a fixed IP for your RPi, log on to your NAS find the directions for employing the NFS system. Install it, then go through the directions to allow NFS connection(s) to your “client” RPi on one or more volumes.  In my case I do it fixed-IP by fixed-IP, but I see drawbacks down the road.  It works for now.  (If you don’t know how to set up a fixed IP just Google it.) Note that for most of computer history the first sentence in this paragraph would have read “one or more drives” instead of “one or more volumes”.  If you are a real old hand you need to understand that modern NAS systems work on virtual files systems – not physical ones.  In my case working with a new Synology DS218+ I got to control panel, open shared drives, select the one I want and right click to edit, the select the NFS tab and add my fixed_IP RPi.

JOB TWO::  On your Pi, create a directory to host the external file volume when it is mounted.  Unix shows everything in one big file tree.  Traditionally, /mnt is a good place to stick you virtual folders.  For example if you are going to mount a volume on you NAS called “music”, you might create “mymusic” in the /mnt folder.  You would then be able to see (in a Raspian workspace on your Pi) all your music on the external drive by typing “ls /mnt/mymusic”.

JOB THREE:: The fstab file is found at /etc/fstab – engrave that on your wrist.  For every volume (not drive) to which  you want to connect, you will need an entry to provide directions when it comes time to run a “mount -a” command.  The general format is: [external file system] [directory to host the file system] [type – in this case “nfs”] [optons – there are quite a few] [dump – ignore] [pass – probably ignore].

The default option values are: rw, suid, dev, exec, auto, nouser, and async. For the sake of making the mount command work you may want to throw in nofail, and user and then add  x-systemd.device-timeout=10s for each device that might be offline.

JOB FOUR: Create a text file which (in the next step) we will run to implement establishing connections to the one or more volumes that you set up in fstab.  For example, right in the home directory you might create a file called “mystart” and it could contain just the line “sudo mount -a”.  It could also contain other text commands but I would keep it simple to start.

JOB FIVE:  put a line at the end of “.bashrc” – which you will find in your home directory – that runs the command file you created in job four.     “./” plus the file name should do it.  For example ./mystart.  To see the “.bashrc” file in linux you will need to add the “-a” modifier to the “ls” command – “ls -a”.

JOB SIX: NONE of this automatically transpires when you boot your RPi into the Pixel desktop; but as soon as you open terminal, it will automatically executes.  You can then close terminal and find your linked volumes in the mnt folder (if that is where you set them up) using Pixel’s GUI file system.