Pi NAS network drive

I am trying to connect my network NAS drive to my PI
Have followed this link: CAGE Web Design | Raspberry PI - mounting a network drive - CAGE Web Design

I created a folder /home/pi/X
I have edited file //etc/fstab by adding to the bottom:
//192.168.1.7/home/pi/X cifs guest,_netdev 0 0
sudo mount /home/pi/X

I get this response:
mount: /home/pi/X: can’t find in /etc/fstab.

Why does this not work? how can I get it to work?

1 Like

Here’s the first result from a quick google:

Looks like it answers your question :slight_smile:

1 Like

This is all gobbldy gook!
Can someone please tell me how I can mount the drive NAS drive which I have specified to my Pi please?

Under windows explorer I can see my NAS drive displayed as: ARC (\nas-E5-BA-5B) (X:)
I have verified using ping that the ip address of this NAS drive on my network is: 192.168.1.7
I do not have any password access requirement.

I want it mounted on my Pi - how do I do it please?

There are two of ‘/’ in front of nas , last post did not print both for some reason.

Hi Clem,

I had a look at this guide and found it super useful. You appear to have missed a space in //192.168.1.7/home/pi/X (should be //192.167.1.7 /home/pi/X, and mount is interpreting it as the first argument rather than first and second. Here’s an example of how this file is formatted:

While following simple guides like the one you linked can be very useful, it’s best to understand the underlying mechanisms to what you’re doing (for example how the _netdev argument holds off on mounting until network is up)

Hope this sorts you out!
-James

Hi James - we are starting to get somewhere:
I replaced the line with:
//192.168.1.7/ARC /home/pi/X cifs guest,_netdev 0 0
the mount command does not give any error now and after reboot and then run mount command again the NAS drive is loaded - good!

when I reboot, it is lost and I have to run the mount command again to mount the NAS drive.

How do I set this up so that I do not have to re run the mount command after each reboot?

Regards

This is a great article on how to ask a good question - it’s focused on programming but the principles apply everywhere:

Gobbledygook? That just means you have more to learn before solving your immediate problem. Don’t ask to be spoonfed - if that’s what you’re after you’re really just looking to have someone do your work for you - and that’s something you should be paying for. Forums are places of community and learning.

You should seek to learn, and, if you don’t understand, take some initiative to research and then ask another question when you’ve made an attempt to further your knowledge.

It’s a lot more fun and enjoyable for everyone that way. Else, if you don’t put in the effort to self learn you can hardly expect anyone to put in the effort to teach.

Please consider how you would feel if someone spoke to you the way you just spoke to me, after making an effort to assist them.

4 Likes

I setup network shares all the time on our Ubuntu VMs. The process would be much the same for Raspberry Pi OS.

Step 1 - Backup your uSD - because you can brick the OS with typos in fstab and RPi OS doesn’t support GRUB for easy fixes.

Install CIFS:

sudo apt-get install cifs-utils

Create a credentials file (I do this so that special characters don’t affect fstab) /etc/cifauth

sudo nano /etc/cifsauth

Add this to /etc/cifauth

username=NAS_USER
password=NAS_USER_PW

Adjust chmod for /etc/cifauth

sudo chmod 600 /etc/cifsauth

Create the target directory (which basically becomes a symbolic link for the mounted drive). Change TARGET with your preferred foldername

sudo mkdir /media/TARGET

Edit fstab

sudo nano /etc/fstab

Add a new line to /etc/fstab and edit NAS_STATIC_IP, NAS_FOLDER_NAME, TARGET based on your preferences

//NAS_STATIC_IP/NAS_FOLDER_NAME /media/TARGET cifs guest,uid=pi,gid=pi,credentials=/etc/cifsauth,nofail 0 0

uid=pi and gid=pi can be modified if you have changed the default user on the RPi.

And as always, never reboot an operating system after editing fstab without first testing…

sudo umount /media/nas_share/
sudo mount -a

While you may get a warning/error on the first command above (because it was already unmounted), the second command should not error. If untested and there is a typo, you may brick your operating system on the next boot and it gets more complicated quickly.

And that’s it. The whole process will be fully automated every boot.

When the RPi boots, there is a risk that the NAS is offline. This isn’t a huge issue as the fstab option nofail is set (the RPi will boot fine, however, no folder will be mounted). When the NAS is online again either restart the RPi (likely preferrable) or run this command to invoke the fstab configurations:

sudo mount -a

5 Likes

Hi Oliver

Well said and sadly seems to be true in many cases. Especially re finding parts. Myself and most others are quite happy to point a person with a problem in the right direction if the direction is known, but such person must be prepared to do some searching themselves. After all it is only they know (or should know) exactly what they want or need. An awful lot can be learned along the way least of all how to apply filtering when searching catalog items. Element 14 and RS for instance have many many thousands of line items and without some filtering can literally take hours to browse.
Cheers Bob

4 Likes

Not asking to be spoon fed as some kind on useless dope! and YES there is a lot of cryptic gobbldygook! out there that imparts no understanding and there is the risk of chasing this wind just to find that the entire time is wasted! We cannot know everything - the field is far too wide and if one pursues knowing everything through own research one achieves nothing to completion and finishes with no job and dead!
For me the issue of getting NAS working on Pi is side issue which cannot dedicate large recourse to and aught to be simple. I did research this for a day and got nowhere. The link I provided touted how simple it was to get working and spoke with the typical nose in the air attitude that all I did was this and this and it worked. When I try exactly the same thing it does not work! So I did the sane thing and posted a forum question. I got an answer which was neither helpful or imparted any understanding. So I use the term gobbledygook and for that I must get rapped over the knuckles for daring to look like one who is stubborn about leaning anything. You guys out there are experts in experience in all kinds of things and I expect happy to show your mastery of the subject in good teacher fashion of shedding light so that the simple can follow and understand easily. Surly the question I asked was not in the difficult unusual basket and I was unable to find suitable answerer in reasonable timeframe.
Regards

Back on topic, how did you go with our advice?

2 Likes

James pose 2 d ago has got me out of immediate trouble. That is changing the /etc/stab file to:
//192.168.1.7/ARC /home/pi/X cifs guest,_netdev 0 0’
made all the difference. I had to add whitespace prior to /home…
AND I realized that I needed /ARC
Once I realized this the command worked and the NAS mounted as required.

It did not stay mounted after reboot and I will examine the following post to consider how to do this.
Right now I have to work on something else or I do not get paid - so I will come back to this in perhaps a week to resolve how I need to make this non volatile.

Thankx

4 Likes

Have you tried testing the fstab config by first unmounting:

/home/pi/X

and then running:

sudo mount -a

The above command is essentially what is invoked during boot. If there is a problem, it will say why.

If it connects fine, then perhaps your network is not being established fast enough on boot. In which case, from terminal run sudo raspi-config and set the option Boot options - Wait for network at boot.

Let me know if that works.

5 Likes

I have reboot the PI and the NAS mount is gone
I type sudo mount -a
and the mount is established.
but when I reboot it comes up without the mount until I mount -a again

1 Like

Hi Clem,

Strange… As Graham has mentioned, sudo mount -a is only allowed to work with information in fstab, so it seems to be pointing to the network connection being ready. Here’s a stackoverflow link that into the symptoms you’ve reported that I found some info on. It links to another thread about setting up the mount task elsewhere (init.d) so it waits even longer for network connectivity.

Have you tried Graham’s suggestions yet? (raspi-config etc?)

Keen to see this come together!
-James

2 Likes

Hey Clem,

How did you go with this ? I was looking to setup a NAS myself soon with a Pi :smiley:

3 Likes

Hi Liam,

Sorry for taking so long to reply to you.

I got the NAS to show on the desktop of the PI and thought that the problem was solved.

Some time later I tried to transfer a file and it would not work - so still not fixed. I have had to move on to a more urgent problem and will come back to this when I can.

If you have some joy please let me know.

Regards

3 Likes

Hi Clem,

Thank for letting us know, no worries about the delay. It shouldn’t be required if the setup as Graham ran through earlier in this discussion in editing etc/fstab and ensuring that nofail is set correctly in this file then restarting the Pi should initialize the connection to the NAS server.

That being said, a somewhat hacky way to get around this issue is by editing your rc.local using sudo nano /etc/rc.local and just adding sudo mount -a & to the end of the file and saving so that it gets called at boot. (The & just ensures that the process is forked so that if there is some typo or issue with it that would cause your Pi appear to freeze at boot other processes can continue to run so you can more easily fix the issue by killing the process and editing rc.local again)

The Raspberry Pi Foundation has some documentation on rc.local if you’re unsure about what this will do:

3 Likes

Hmm. I use this on several RPi’s and it works very well. Including our Pick and Place machine (operates on RPi) so that we can manage production files directly from our PCs via a NAS folder. Never misses a beat.

Good luck with it.

4 Likes