This is a static archive of the old Zorin Forum.

The information below may be outdated. Visit the new Zorin Forum here ›

If you have registered on the old forum, you will need to create an account on the new forum.

Mount remote Windows share at login (not boot)

tk1

Tue Jan 14, 2020 4:15:21 am

Zorin 15.1, updated

I have a pc on my LAN running Windows 7 with a share that I want to mount whenever I log in to Zorin.

I know how to mount it at boot by putting it in fstab, however I'd rather not do it that way. I want to wait and have it mounted automagically when I log in. It needs to be writeable, as well.
To mount it at boot, I put the following in my fstab:

Code:
//windowspc/sharename$ /home/me/windowsshare cifs vers=2.1,username=user,uid=1000,gid=100,dir_mode=0777,file_mode=0666 0 0

I get prompted for the share password for windowspc at boot. Once I log in, the share is there.


Any thoughts on how I can do this when I log in to Zorin? I don't mind, and actually prefer to be prompted for a password for the share when I'm logging into Zorin.

I've been searching for several days how to do this and all I can find is how to do it at bootup, not log in.


Thank you,
tk1

Aravisian

Tue Jan 14, 2020 4:32:07 am

There are a couple of options. All you want to do is mount, but put a delay on it.
The simplest method, that I know works, would be to just make it "wait for the network"
Code:
x-systemd.after=network-online.target

tk1

Tue Jan 14, 2020 11:27:10 am

Aravisian wrote:There are a couple of options. All you want to do is mount, but put a delay on it.


Thank you Aravisian. I'm not looking for a delay, but a way to have it happen at log in, whenever that happens. The network is up before logging in, which is too early to mount the share. You said there are a couple of options?

Thank you,
tk1

Aravisian

Tue Jan 14, 2020 4:51:07 pm

tk1 wrote:
Aravisian wrote:There are a couple of options. All you want to do is mount, but put a delay on it.


Thank you Aravisian. I'm not looking for a delay, but a way to have it happen at log in, whenever that happens. The network is up before logging in, which is too early to mount the share. You said there are a couple of options?

Thank you,
tk1

Delay= Until you login.

Did you set up your network to be up before you login? Because that is not default.

tk1

Wed Jan 15, 2020 1:57:43 am

Aravisian wrote:Did you set up your network to be up before you login? Because that is not default.


Yes, I did.
So, wouldn't that mean the share might still get mounted prior to logging in?

Aravisian

Wed Jan 15, 2020 2:33:23 am

tk1 wrote:
Aravisian wrote:Did you set up your network to be up before you login? Because that is not default.


Yes, I did.
So, wouldn't that mean the share might still get mounted prior to logging in?

Honestly, I am not really sure, but I suspect you are probably right.

Looking at this site here:
https://www.fosslinux.com/4216/how-to-a ... ubuntu.htm
Scroll down to Step 5 and you will see there is an option:
"Require additional authorization to mount"

tk1

Wed Jan 15, 2020 2:53:28 am

if there is only one account in your PC, which implies it’s that of the administrator, this setting does not affect.


So, unfortunately that won't work for me.

Aravisian

Wed Jan 15, 2020 3:12:18 am

tk1 wrote:
if there is only one account in your PC, which implies it’s that of the administrator, this setting does not affect.


So, unfortunately that won't work for me.

Well... Setting it to noauto in fstab is not what you want because you want it to automount.
Have you tried autofs?
https://help.ubuntu.com/community/Autofs

The last option would be to create a script to automount it after you login. I have made a few scripts, but I have never made that one. I'd have to research it to ensure I do not say anything that leads you astray.

tk1

Wed Jan 15, 2020 4:00:44 am

Aravisian wrote:Well... Setting it to noauto in fstab is not what you want because you want it to automount.


Correct. I did try that and then put a mount command in Startup Applications hoping it would mount after logging in, however that didn't work. The logs showed me mount with options requires sudo.

Aravisian wrote:Have you tried autofs?
https://help.ubuntu.com/community/Autofs


I have not, and although it says it's better on bandwidth because it will unmount them after a period of time, that's not what I'm looking for. I want the mounted share to be available all the time. I may have to end up resorting to this though, if there isn't another better (for me) way.


Aravisian wrote:The last option would be to create a script to automount it after you login. I have made a few scripts, but I have never made that one. I'd have to research it to ensure I do not say anything that leads you astray.


I'm definitely up for this if it's possible and I would appreciate the assistance. I know a very little about scripting, but not afraid to try it as long as I can understand it.

Aravisian

Wed Jan 15, 2020 4:07:15 am

tk1 wrote:I'm definitely up for this if it's possible and I would appreciate the assistance. I know a very little about scripting, but not afraid to try it as long as I can understand it.

Then let's set this as the priority option.
I'll ask for help because while I don't mind messing up my own machine trying untried things, I'd rather not do it to you.
Will report back here a link to thread.

tk1

Wed Jan 15, 2020 4:18:51 am

Aravisian wrote:Then let's set this as the priority option.
I'll ask for help because while I don't mind messing up my own machine trying untried things, I'd rather not do it to you.
Will report back here a link to thread.


lol. Thank you, I appreciate all your help!

Aravisian

Wed Jan 15, 2020 4:48:50 am

https://forum.xfce.org/viewtopic.php?pid=56096#p56096
You can follow along the thread there. Registering on the site is kind of.... annoying... (Try it out, you'll see what I mean...)
But I can relay back and forth.

Aravisian

Wed Jan 15, 2020 9:06:04 pm

https://forum.xfce.org/viewtopic.php?pid=56105#p56105
ToZ said:


Personally, I use autofs for this. The drives aren't actually mounted until you click on (or enter) the mount point. For more info, see https://wiki.archlinux.org/index.php/Autofs.

However, if you are looking for a script to run, you can use gvfs/gio to automate mounts. To make so that you don't have to enter in credentials, first create the file ~/.creds with the following content:

Code:
username
workgroup
password


...so it looks something like this:

Code:
toz
WORKGROUP
mypassword


Then you can use a command like this:

Code:
gio mount smb://Server/Music < .creds


...to mount the remote share (in this case an smb share). It will show up in thunar as a mounted volume in the NETWORK section.

You can create a script to do multiple mounts:

Code:
#!/bin/sh
gio mount smb://Server/Music < .creds
gio mount smb://Server/Pictures < .creds
gio mount smb://Server/Videos < .creds


...and add it to your autostart applications to have it start when you log in.

tk1

Thu Jan 16, 2020 3:45:53 am

Unfortunately, this doesn't work because I don't want a password in a clear text file.

I tried putting only the user and domain in the .creds file hoping it would prompt me for the password, but it doesn't. I tried this from a terminal with that .creds file, but it doesn't prompt and wait for the password.

If I could get it to prompt me for the password, I think this would work, but I don't see an option for that. Even though the man page says:
...the mount command may ask for user IDs, passwords, and so on, when required"

it doesn't seem to.

Swarfendor437

Thu Jan 16, 2020 1:13:04 pm

You need to tell your Windows Machine Share options to require Password methinks? :o

tk1

Fri Jan 17, 2020 1:28:38 am

Swarfendor437 wrote:You need to tell your Windows Machine Share options to require Password methinks? :o


Since the share already has restricted permissions, it requires a username/password to connect.