Edwardnzz
Posts: 8
Joined: Fri Nov 08, 2019 3:36 pm
Location: New York, USA

Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Thu Nov 14, 2019 2:06 am

Hi all!
My goal is to have my shared network folder mount on boot.

This is the path in windows:
\\READYSHARE\mynas

I created a folder:

Code: Select all

Sudo Mkdir /media/mynas
Then set permissions:

Code: Select all

Sudo chmod 777 /media/mynas
Than tried to mount("READYSHARE" did not work):

Code: Select all

sudo mount //192.168.1.99/mynas /media/mynas
I got:
Password for root@//192.168.1.99/mynas: *********
I entered the password and the folder was mounted(Yay!) :
pi@raspberrypi:/ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 1.4G 27G 5% /
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 8.5M 1.9G 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 52M 201M 21% /boot
tmpfs 391M 0 391M 0% /run/user/1000
//192.168.1.99/mynas 299G 99M 298G 1% /media/mynas

So I know I could mount the network drive pretty easily.

I umounted the drive and tried to mount it again like this:

Code: Select all

sudo mount -o username=pi,password=Raspberry //192.168.1.99/mynas /media/mynas
That was successful as well.

But then i tried to edit fstab to get the drive to mount on boot:

Code: Select all

//192.168.1.99/mynas /media/mynas auto username=pi,password=Raspberry,workgroup=WORKGROUP,users,auto,user_xattr 0 0
When I reboot, I get this:
cannot open access to console the root account is locked see sulogin 8 man page for more details.

I press enter and it just displays the same message.

So I'm going to reload the Raspbian image and try again and maybe some kind soul out there could give me the code for fstab I need to make it work.

I would like all user and group access and R/W access.

Being very unfamiliar with linux, it took me weeks to get to this point. If I could get this to work I would be ecstatic!
Thanks!

dustnbone
Posts: 259
Joined: Tue Nov 05, 2019 2:49 am

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Thu Nov 14, 2019 4:34 am

Here's what I use to mount Windows shares in fstab

//192.168.1.85/dump /home/pi/dump/ cifs username=user,password=pass,iocharset=utf8,file_mode=0777,dir_mode=0777,automount

It works, it's probably not "correct" but I hate SMB so much that as soon as it works I stop playing with it.

jj_0
Posts: 113
Joined: Wed Jul 11, 2012 7:07 am

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Thu Nov 14, 2019 5:44 am

To test changes to /etc/fstab, unmount (if mounted) the newly added drive an then execute:

Code: Select all

mount --all
This helps to see if there are any errors. However normally if the system can't mount an fstab entry during bootup you will be dumped into a maintenance console so your error message might point to something else.
Also, adding 'nofail' to the options of your fstab entry will tell the system it's OK if it can't mount the share during startup.

You could try editing the fstab from another PC if you have one.

Also this thread might help you.

LTolledo
Posts: 3321
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Thu Nov 14, 2019 6:10 am

here is my version of mounting my NAS shares

Code: Select all

//192.168.211.205/HDD1    /mnt/RPi3BpNAS   cifs   credentials=/root/.cifuser,nofail,vers=1.0,x-systemd.automount 0 0  
where the userid and password are stored in a hidden file /root/.cifuser

if you want to force specific user/group privileges you may do it this way

Code: Select all

//192.168.211.205/HDD1    /mnt/RPi3BpNAS   cifs   credentials=/root/.cifuser,userid=username,gid=groupname,nofail,vers=1.0,x-systemd.automount 0 0  
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

User avatar
thagrol
Posts: 2961
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Thu Nov 14, 2019 11:54 am

In my experience adding "_netdev,nofail" to the mount options usually sorts this out.

"_netdev" tells systemd that it;'s a network device and to not attempt to mount it until the network is ready.

"nofail" means don't stop boot if the mount fails. The device won't be mounted but, unless it's the device containing the root partition, your Pi will still boot.

I strongly advise inculding "nofail" when messing with /etc/fstab especially when trying to mount USB or network devices that may not be present on every boot.

To fix your broken fstab you'll need another linux PC (windows can't mount the ext4 root partition). This can be another Pi, another SD card in the same Pi, a desktop/laptop with linux installed, or a desktop/laptop running linux from a live CD/DVD/USB.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

Edwardnzz
Posts: 8
Joined: Fri Nov 08, 2019 3:36 pm
Location: New York, USA

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Fri Nov 15, 2019 12:41 am

Success (YAY!!)
I want to respond with all the steps in order just in case someone happens to have a similar problem on their Raspberry Pi 4.
1. Being I couldn't log in, I reformatted and flashed the memory card with the Raspbian lite image file using Etcher.
2. inserted the drive, logged in, configured my network.
3. Did all the updates/upgrades.
4. Made the Directory:

Code: Select all

mkdir /media/mynAS
5. To add credentials I gave myself root access:

Code: Select all

sudo su 
Edited the .cifuser:
sudo nano /root/.cifuser
Then typed:
username=me
password=mycomplexpassword
(Thank you LTolledo)

Then hit Ctrl + x then y and enter.

5. Changed user back to Pi

Code: Select all

su pi 
6. Edited fstab:

Code: Select all

sudo nano /etc/fstab
Add the line above the # symbol:

Code: Select all

proc            /proc           proc    defaults          0       0
PARTUUID=6c586e13-01  /boot           vfat    defaults          0       2
PARTUUID=6c586e13-02  /               ext4    defaults,noatime  0       1
//192.168.1.99/mynas    /media/mynas   cifs   credentials=/root/.cifuser,_netdev,nofail,vers=1.0,x-systemd.automount 0 0
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
Made sure i used "_netdev" (Thanks thagrol) in the options.

Then hit Ctrl + x then y and enter.
7. Tested the Fstab:

Code: Select all

mount --all 
( thanks jj_0 )

8. Verified that I could access network directory.

Code: Select all

cd /media/mynas

Code: Select all

ls -la

Code: Select all

total 4
drwxr-xr-x 1 root root    0 Nov 13 17:45 .
drwxr-xr-x 3 root root 4096 Nov 14 17:51 ..
drwxr-xr-x 1 root root    0 Nov 13 17:44 test
drwxr-xr-x 1 root root    0 Nov 13 17:45 test2
(Yay!)

Added a folder in the Network directory:

Code: Select all

sudo mkdir pictures


9. Rebooted

Code: Select all

sudo reboot
Once rebooted,(No problem rebooting!) I did another ls command:

Code: Select all

ls -la

Code: Select all

total 4
drwxr-xr-x 1 root root    0 Nov 14 18:43 .
drwxr-xr-x 3 root root 4096 Nov 14 17:51 ..
drwxr-xr-x 1 root root    0 Nov 14 18:43 pictures
drwxr-xr-x 1 root root    0 Nov 13 17:44 test
drwxr-xr-x 1 root root    0 Nov 13 17:45 test2
(YEAAAA!!!)

This is and will continue to be a cool learning experience.
Thank you guys so much for your help. I truly appreciate it!

jj_0
Posts: 113
Joined: Wed Jul 11, 2012 7:07 am

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Fri Nov 15, 2019 6:20 am

Glad you got it to work, and thanks for reporting back.

LTolledo
Posts: 3321
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Fri Nov 15, 2019 7:04 am

Glad you had it working.....

however.... i noticed that the shares are owned by root

if you are logged in as let's say pi, those mounted shares will not be available to you, only to root.

its either you set ownership and access rights using chown and chmod

or specify the userid and groupid at fstab (the mounted shares will have the same user/group rights granted to the user specified in userid/groupid)
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

Edwardnzz
Posts: 8
Joined: Fri Nov 08, 2019 3:36 pm
Location: New York, USA

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Fri Nov 15, 2019 10:14 am

I did notice that I could could not add a subfolder under test or the pictures folder i made as pi. Could I use an allow all where the options are? What would that line look like in fstab?

I should add that I want to allow read write access by all or any program that may need to write in those network folders.

User avatar
thagrol
Posts: 2961
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Fri Nov 15, 2019 12:23 pm

LTolledo wrote:
Fri Nov 15, 2019 7:04 am
its either you set ownership and access rights using chown and chmod
Given that it's a cifs/samba share being mounted chown and chmod are unlikely to do anything.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

User avatar
thagrol
Posts: 2961
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Fri Nov 15, 2019 12:30 pm

Edwardnzz wrote:
Fri Nov 15, 2019 10:14 am
I should add that I want to allow read write access by all or any program that may need to write in those network folders.
SImplest fix is to add

Code: Select all

umask=000
to your mount options to give full read/write/execute permissions to all users.

Make the change then

Code: Select all

sudo mount -o remount /media/mynAS
No need to reboot.

You should be aware though that the server has to allow write access else permissions on the Pi won't matter.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

Edwardnzz
Posts: 8
Joined: Fri Nov 08, 2019 3:36 pm
Location: New York, USA

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Fri Nov 15, 2019 6:01 pm

I'll try this weekend and post updates. Thanks again.
Btw, when you mention the server, do you mean the network folders im mounting? Because those are on a netgear readyshare thats open with no passwords to access.

User avatar
thagrol
Posts: 2961
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Fri Nov 15, 2019 8:14 pm

Edwardnzz wrote:
Fri Nov 15, 2019 6:01 pm
I'll try this weekend and post updates. Thanks again.
Btw, when you mention the server, do you mean the network folders im mounting? Because those are on a netgear readyshare thats open with no passwords to access.
Yep.

I don't have one of those so can't comment directly on it. In general for network folders you need three things set correctly to be able to write to it:
  1. The server drive containging the shared folder has to be mounted read/write on the server (your netgear readyshare)
  2. Permissions on the server on the sahred folders need to be set to allow write access.
  3. The network folders need to be mounted rw (read/write) on the client (your Pi)
  4. Local permissions on the cleint must allow writing for the local user attmpting to do so.
OK, that's four things ;)

None of thse stages can provied write access if an earlier one denies it.

For cifs/samba permission are set at mount time, apply to the client only, are the same for all files and canot be changed with chmod or chown. Default permissions are to allow write access for the user mounting the network share (Defaults to root when mounting via fstab) and deny writing for eveyone else.

The above is the simple version. There's a lot I've left out as it either doesn't apply to or is unlikely to be supported by your readyshare.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

Edwardnzz
Posts: 8
Joined: Fri Nov 08, 2019 3:36 pm
Location: New York, USA

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Sun Nov 17, 2019 2:16 pm

So far, I've given full access to the network folders I'm interested in using.
pi@raspberrypi:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 2.5G 26G 9% /
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 2.0G 16K 2.0G 1% /dev/shm
tmpfs 2.0G 113M 1.8G 6% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 52M 201M 21% /boot
tmpfs 391M 0 391M 0% /run/user/1000
//192.168.1.99/mynas 299G 99M 298G 1% /media/mynas

used chown to give R/W permissions:

Code: Select all

pi@raspberrypi:/media $ ls -la
total 8
drwxr-xr-x  3 pi   pi   4096 Nov 16 20:24 .
drwxr-xr-x 21 root root 4096 Sep 26 01:24 ..
drwxrwxrwx  1 pi   pi      0 Nov 16 21:47 mynas
pi@raspberrypi:/media $ cd mynas
pi@raspberrypi:/media/mynas $ ls -la
total 20
drwxrwxrwx 1 pi pi     0 Nov 16 21:47 .
drwxr-xr-x 3 pi pi  4096 Nov 16 20:24 ..
drwxrwxrwx 1 pi pi     0 Nov 16 21:56 downloading
-rwxr-xr-x 1 pi pi 13515 Nov 16 21:11 lds-deploy-v3.sh
drwxrwxrwx 1 pi pi     0 Nov 16 21:45 sonarr
-rw-r--r-- 1 pi pi     0 Nov 16 21:47 sonarr_write_test.txt
drwxrwxrwx 1 pi pi     0 Nov 13 22:44 test
drwxrwxrwx 1 pi pi     0 Nov 13 22:45 test2
I think I have fstab setup?

Code: Select all

proc            /proc           proc    defaults          0       0
PARTUUID=6c586e13-01  /boot           vfat    defaults          0       2
PARTUUID=6c586e13-02  /               ext4    defaults,noatime  0       1
//192.168.1.99/mynas    /media/mynas   cifs   credentials=/root/.cifuser,_netdev,nofail,vers=1.0,x-systemd.automount 0 0
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
Yet when I installed sonarr and go to add new series, sonarr lets me browse to the folder , but wont add it.
when looking at the sonar log it says:
-- Path: Folder is not writable by user sonarr
I don't know what else to do. I have the user as pi for these folders.

In Sonarr,On the web gui, in settings - media management
Permissions
Set Permissions
File chmod mode
0644
Octal, applied to media files when imported/renamed by Sonarr
Folder chmod mode
0755
Octal, applied to series/season folders created by Sonarr
chown User
1000
Username or uid. Use uid for remote file systems.
chown Group
1000

This should match my pi:

Code: Select all

pi@raspberrypi:/media/mynas $ id
uid=1000(pi) gid=1000(pi) groups=1000(pi),4(adm),20(dialout),24(cdrom),27(sudo),29(audio),44(video),46(plugdev),60(games),100(users),105(input),109(netdev),997(gpio),998(i2c),999(spi)
I know I'm doing something wrong, I couldn't figure out where to put the unmask=000 command either.

User avatar
thagrol
Posts: 2961
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Sun Nov 17, 2019 2:28 pm

Edwardnzz wrote:
Sun Nov 17, 2019 2:16 pm
I know I'm doing something wrong, I couldn't figure out where to put the unmask=000 command either.
Try changing you fstab entry to

Code: Select all

//192.168.1.99/mynas    /media/mynas   cifs   credentials=/root/.cifuser,_netdev,nofail,vers=1.0,umask=000,x-systemd.automount 0 0
Without that change only the user "root" on the Pi will have write access.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

Edwardnzz
Posts: 8
Joined: Fri Nov 08, 2019 3:36 pm
Location: New York, USA

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Sun Nov 17, 2019 3:29 pm

Ok unmask seems to have caused a problem for me.
I cant access the mynas directory:

Code: Select all

pi@raspberrypi:~ $ cd /media/mynas
bash: cd: /media/mynas: No such device
pi@raspberrypi:~ $ cd /media
pi@raspberrypi:/media $ ls -la
total 8
drwxr-xr-x  3 pi   pi   4096 Nov 16 20:24 .
drwxr-xr-x 21 root root 4096 Sep 26 01:24 ..
drwxr-xr-x  2 root root    0 Feb 14  2019 mynas
also tried the same as root user:

Code: Select all

pi@raspberrypi:~ $ sudo su
root@raspberrypi:/home/pi# cd /media/mynas
bash: cd: /media/mynas: No such device
root@raspberrypi:/home/pi# cd /media
root@raspberrypi:/media# ls -la
total 8
drwxr-xr-x  3 pi   pi   4096 Nov 16 20:24 .
drwxr-xr-x 21 root root 4096 Sep 26 01:24 ..
drwxr-xr-x  2 root root    0 Feb 14  2019 mynas
root@raspberrypi:/media#
My latest fstab update:

Code: Select all

proc            /proc           proc    defaults          0       0
PARTUUID=6c586e13-01  /boot           vfat    defaults          0       2
PARTUUID=6c586e13-02  /               ext4    defaults,noatime  0       1
//192.168.1.99/mynas    /media/mynas   cifs   credentials=/root/.cifuser,_netdev,nofail,vers=1.0,umask=000,x-systemd.automount 0 0
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
Yet, when I change the fstab back to what i had before, I can now access mynas directory:

Code: Select all

pi@raspberrypi:~ $ cd /media/mynas
pi@raspberrypi:/media/mynas $
Could I be missing something else?

User avatar
thagrol
Posts: 2961
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Sun Nov 17, 2019 4:32 pm

Edwardnzz wrote:
Sun Nov 17, 2019 3:29 pm
Could I be missing something else?
Very possibly. However I don't use either the credentials= or the x-systemd.automount mount options. I've not found them necessary when mounting public samba/cifs/windows shares.

I'd try something like this to simplify things.

Code: Select all

//192.168.1.99/mynas    /media/mynas   cifs   defaults,_netdev,nofail,guest,vers=1.0,umask=000 0 0
  • "defaults" is a just in case inclusion to ensure sensible values where you don't otherwise specify them.
  • You only need a credentials file if your NAS restricts logins to particular (local to the NAS) users or needs a password which you've said it doesn't.
  • "guest" means don't prompt for a password and try to login without one.
  • Order is important for mount options. Later ones override earlier ones.
If you want to test that before modding your fstab and without a reboot try this:

Code: Select all

sudo umount /media/mynas
sudo mount -t cifs -o  defaults,_netdev,nofail,guest,vers=1.0,umask=000 //192.168.1.99/mynas /media/mynas
"sudo umount" may error if the share isn't already mounted. That can be ignored.


I'm not sure what other advice I can offer. Sorry.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

Edwardnzz
Posts: 8
Joined: Fri Nov 08, 2019 3:36 pm
Location: New York, USA

Re: Trying to mount a network folder on boot. After fstab edit pi locks on reboot.

Sun Nov 17, 2019 5:31 pm

Hey, Don't be sorry. You have been a great help. Even if this doesn't work for what I'm trying to do, I have learned so much about a operating system that I knew nothing about a few weeks ago. All good and I'm gonna keep pushing!

Return to “Troubleshooting”