You are not logged in.

#1 2015-05-18 14:49:43

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

Permanently mapping a local file to a network folder using samba?

Hi there,

I'm attempting to use samba to connect my media folder in my home directory with with my media on my NAS. This command gave the desired effect however is not permanent:

sudo mount –t cifs –o username=leaf,password=password //192.168.1.93/Media /home/leaf/media

I did a little research and added it to my fstab:

//192.168.1.93/Media    /home/leaf/media        cifs    credentials=/home/leaf/.smbcredentials             0     2

when I use sudo mount -a, this works fine, however the issue then is when I attempt to reboot my pc I get a message: A start job is running for sys-subsystem-net-devices-eth0.device. This remains until it times out after one and a half minutes.

When I log in, the device is then mounted and everything works as desired, however, I would prefer to be able to avoid this hang.

I read about and found someone mentioning that it was due to the way that they connected to the internet using dhcpcd@eth0.service (enp2s0 in my case). This was the way I was connecting. So I attempted to connect with netctl and couldn't get it to connect at all. I'm not using networkd instead:

/etc/systemd/network/wired.network

[Watch]
Name=enp2s0

[Network]
DHCP=ipv4

This connects me to the internet fine, but the sys-subsystem-net-devices-eth0.device delay still occurs.

I attempted to add the mounting to my .xinitrc by with a shell script. I created a file called .startscript which included this: sudo mount –t cifs –o username=leaf,password=password //192.168.1.93/Media /home/leaf/media. I then chmod u+x it and added "sh .startscript &" to my .xinitrc; this of course didn't work.

So I edited my sudoers file and added this line: leaf ALL=(ALL) NOPASSWD: /home/leaf/.startscript then added "sudo sh .startscript &" to my .xinitrc and still had no luck.

Not quite sure where to go from here, any help would be highly appreciated.

Offline

#2 2015-05-18 14:55:59

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: Permanently mapping a local file to a network folder using samba?

If you stick with the fstab solution, but add

noauto,x-systemd.automount

to the options, it won't mount at boot, but will mount when you access the folder.
It will also mean that the -a option in the mount command won't mount it.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#3 2015-05-18 15:05:14

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Permanently mapping a local file to a network folder using samba?

I solved a similar problem with my NFS mounts by creating mount units for them instead of using fstab, and putting

After=wpa_supplicant-nl80211@wlan0.service network-online.target

in the [Unit] section. You would of course use

sys-subsystem-net-devices-eth0.device

there instead of my wpa_supplicant service.

Offline

#4 2015-05-18 15:06:52

Gwynplaine
Member
From: England.
Registered: 2014-11-11
Posts: 32

Re: Permanently mapping a local file to a network folder using samba?

Wow that was an incredibly quick response, thank you! to think that something that kept me up so late last night could be fixed with such ease.

Out of curiosity though, would there be a way to initiate it with the login manager (slim) or when i3 starts? If not, that's fine. I really appreciate your help.

Edit: I'll give that a go now, tomk. Thanks!

Last edited by Gwynplaine (2015-05-18 15:08:14)

Offline

Board footer

Powered by FluxBB