You are not logged in.
Hi - having a problem gettring a network drive to mount at boot using scripts and sudoers.d. I have a network drive, but I only want to try and mount it at boot if I'm in my network. I have a script that is:
run by "Sessions and Startup" that calls:
an entry in sudoers.d which doesn't require password entry that calls:
a script in a folder owned by root to mount the drive
However, the drive does not mount and I get the following error in the logs
pam_unix(sudo:auth): conversation failed
pam_unix(sudo:auth): auth could not identify password for [user]I know the script to mount the drive is running because I have it send a message once it starts and I get the message.
If I run from terminal, the script run by "Sessions and Startup", the chain of events noted above is executed and the drive mounts with no request for password.
I have other scripts for other activities that I run through sudoers.d and they work as expected.
It's odd that it works for me when run via terminal, but not when called by "Sessions and Startup".
Any thoughts would be appreciated.
Last edited by Gotit (2019-07-06 13:21:24)
Offline
With an active session, you can mount drives using udev, without the need for elevated privileges. See https://wiki.archlinux.org/index.php/Ud … s_in_rules
Offline
I only want to try and mount it at boot if I'm in my network
Offline
@seth Thanks for NM Dispatcher info. I've installed the scripts modified with my connection's UUID and activated the Dispatcher. When I boot I see it running, but it can't mount the drive because there's no entry for it in /etc/fstab:
systemd[1]: Started Network Manager Script Dispatcher Service.
nm-dispatcher[800]: req:1 'up' [wlp2s0]: new request (1 scripts)
nm-dispatcher[800]: req:1 'up' [wlp2s0]: start running ordered scripts...
nm-dispatcher[800]: req:2 'connectivity-change': new request (1 scripts)
nm-dispatcher[800]: req:2 'connectivity-change': start running ordered scripts...
nm-dispatcher[800]: mount: /mnt/Netdrive-Files/: can't find in /etc/fstab.If I place an entry for the drive in fstab, the system will simply try to mount it on each boot, regardless of nm-dispatcher. If I'm in my network the drive will mount, otherwise it will error out. I must be missing a point here somewhere, what is it?
Last edited by Gotit (2019-07-04 13:39:03)
Offline
Add it to the fstab with the noauto option, that way fstab will ignore it for automounting but you will still have the same lookup guarantees so that you don't have to specify the entire mount command in the manual mount invocation
Last edited by V1del (2019-07-04 13:39:15)
Offline
https://wiki.archlinux.org/index.php/Fs … al_devices
You can try adding an fstab entry with "noauto,nofail" options.
There is also this: https://wiki.archlinux.org/index.php/Ne … ait_Online
Offline
WOW, thanks for all the assist, guys...
Reading through fstab wiki, I'm now thinking mounting on demand would be a better option than just mounting at boot if in network. On demand means I won't be carrying the connection overhead until I need it.
So, off to fstab I went. I can make an entry that mounts at boot, but can't seem to get it to work in an on demand mode. Here's the pertinent entry I'm trying to use for on demand mount:
//[IP Address]/netdrive/Media /mnt/Netdrive-Media cifs guest,vers=1.0,noauto,x-systemd.automount,x-systemd.device-timeout=30,_netdev,iocharset=utf8,sec=ntlm 0 0I'm assuming when I access the folder /mnt/Netdrive-Media via Thunar, that network folder should mount. Maybe, I'm misunderstanding "on demand" in this context.
Offline
I can't seem to get the "on demand" feature to work quite right, and it seems it needs to mount in /etc/media too.
So, settling for the "when in network, mount on boot" feature as originally sought.
@V1del and @2ManyDogs thanks for the "noauto" tip. My final fstab line reads as:
//[driveIP]/netdrive/Files /mnt/Netdrive-Files cifs guest,vers=1.0,noauto,x-systemd.device-timeout=30,_netdev,iocharset=utf8,sec=ntlm 0 0There is another issue brewing where the drive doesn't actually unmount with the
umountcommand even though it reports unmounted! I'll open a another thread if I need assistance.
Offline