SMB connection fails after changing to usb wifi

Kernels & Hardware, configuring network, installing services

SMB connection fails after changing to usb wifi

Postby Plfeenstra » 2021-02-10 09:02

Hi,
On Debian Buster I have created a share to a usb hard disk on my router with smb.
I put the cifs params in fstab and it works fine. At startup it connects beautifully and the share is available.
But when I use a network connection via a usb wifi it fails to connect at startup ('only root can create this share'). When I go back to a ethernet connection and reboot it is ok again.
I guess it has to do with the order: ethernet connection is made before the creation of the share? And the usb wifi connection after?
Thanks for suggestions.
Plfeenstra
 
Posts: 11
Joined: 2021-02-10 08:47

Re: SMB connection fails after changing to usb wifi

Postby Head_on_a_Stick » 2021-02-10 10:50

Perhaps try adding the x-systemd.automount option so that the share is only mounted on demand. See also https://wiki.archlinux.org/index.php/Fs ... filesystem

Disclaimer: I've never used Samba.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13317
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: SMB connection fails after changing to usb wifi

Postby Plfeenstra » 2021-02-10 14:23

ok I tried in fstab:
//192.168.1.17/USB_Storage/ncbackup /media/share cifs noauto,x-systemd.automount,x-systemd.mount-timeout=30,_netdev,uid=0,vers=1.0,credentials=/root/.smbcredentials
When I try to access /media/share with Dolphin I get: mount: /media/share: operation permitted for root only.
That is the same problem as before.
Plfeenstra
 
Posts: 11
Joined: 2021-02-10 08:47

Re: SMB connection fails after changing to usb wifi

Postby Plfeenstra » 2021-02-10 14:37

Extra info: when I connect via ethernet, after a reboot I get the same error message. But when I change the fstab entry back to: //192.168.1.17/USB_Storage/ncbackup /media/share cifs uid=0,vers=1.0,credentials=/root/.smbcredentials
the share is mounted without problems after a reboot and connected via ethernet.

Thanks for suggestions
Peter
Plfeenstra
 
Posts: 11
Joined: 2021-02-10 08:47

Re: SMB connection fails after changing to usb wifi

Postby reinob » 2021-02-10 15:11

Either you mount as root during boot, which seems to work with ethernet in your case, or you mount as user on-demand, which can only work if you also add "users" to the list of options in fstab.

Otherwise systemd will try to mount it automatically on first use, as your user, and not as root, which is alas required by your own /etc/fstab.
reinob
 
Posts: 902
Joined: 2014-06-30 11:42

Re: SMB connection fails after changing to usb wifi

Postby Plfeenstra » 2021-02-11 09:18

reinob wrote:Either you mount as root during boot, which seems to work with ethernet in your case, or you mount as user on-demand, which can only work if you also add "users" to the list of options in fstab.

Otherwise systemd will try to mount it automatically on first use, as your user, and not as root, which is alas required by your own /etc/fstab.


Maybe I didn't make myself clear. I would like to mount the samba share on reboot when only the USB WIFI is available. The mount works fine when connected with an ethernet cable, but not when using USB WIFI.
Plfeenstra
 
Posts: 11
Joined: 2021-02-10 08:47

Re: SMB connection fails after changing to usb wifi

Postby reinob » 2021-02-11 10:27

@Plfeenstra,

Given that during the thread you also tried the on-demand user mounting, I thought you'd like to know how to make that work.

In theory systemd should not try to mount stuff requiring network before ensuring the network is up.
Assuming you haven't tweaked (read: broken) in the systemd units, I can only suggest you review the log ("journalctl -b") which should indicate what failed.

You can of course post it here (or a link to a pastebin, whatever suits you).

PS: which program do you use for making the connection? systemd-networkd, network-manager, ifupdown, ??
reinob
 
Posts: 902
Joined: 2014-06-30 11:42

Re: SMB connection fails after changing to usb wifi

Postby Plfeenstra » 2021-02-11 14:03

Thank you,

I am a beginner,... I have set up the machine to be a Nextcloud server for use at home. For backup purposes I would like to connect to an external (usb) disk-drive that is connected to a router. So far so good.
Everything works fine as long as I connect the server with an ethernet cable to the network. As soon as I use the USB Wifi I get this problem. The 'funny' thing is that when I reboot the machine with de USB WIFI connected it does not mount the share, but as soon as I do sudo mount -a in a terminal, the share is mounted. In the journal / boot.log I see a message that the network could not be reached. It uses network-manager.
I will try to copy the journalctl -b info to a message here.
Plfeenstra
 
Posts: 11
Joined: 2021-02-10 08:47

Re: SMB connection fails after changing to usb wifi

Postby Plfeenstra » 2021-02-11 15:10

I tried the solution from this page: https://www.debian-fr.org/t/resolu-etc- ... ev/80543/3
But unfortunately that didn't work either.
I'll keep searching ;-)
Plfeenstra
 
Posts: 11
Joined: 2021-02-10 08:47

Re: SMB connection fails after changing to usb wifi

Postby reinob » 2021-02-11 16:10

In /etc/fstab, make sure you add the "_netdev" option, so that systemd (which nowadays takes care of mounting stuff during boot) recognizes it as requiring the network to be up before mounting.

//192.168.1... cifs _netdev,uid=0,vers=1.0,credentials=/root/.smbcredentials

It (normally) should work, as long as the connection (ethernet or USB wifi) happens during boot (i.e. before you log in as user, etc.).

Good luck,
(and post your "journalctl -b" if you need more help)
reinob
 
Posts: 902
Joined: 2014-06-30 11:42

Re: SMB connection fails after changing to usb wifi

Postby Plfeenstra » 2021-02-13 13:37

Thanks again,

I created a media-share.mount with the following content:
[Unit]
Description=mount ReadyShare samba share
Wants=network-online.target
After=network-online.target

[Mount]
Environment="SERVER='//192.168.1.17/USB_Storage/ncbackup'"
What=$SERVER
Where=/media/share
Type=cifs
Options=_netdev,users,user,noacl,guest,rw,uid=0,vers=1.0
SloppyOptions=on
DirectoryMode=0755
TimeoutSec=10

[Install]
WantedBy=multi-user.target

It works fine as long I have the ehternet cable connected during boot.
When I try to attach a compressed file to this message I get an error: Sorry, the board attachment quota has been reached.
Is there another way I can share the results of journalctl -b ? I have tried to put it as text in a message like this but that doesn't work either (blank page with error 500 or something like that).

P
Plfeenstra
 
Posts: 11
Joined: 2021-02-10 08:47

Re: SMB connection fails after changing to usb wifi

Postby sunrat » 2021-02-13 20:20

Plfeenstra wrote:When I try to attach a compressed file to this message I get an error: Sorry, the board attachment quota has been reached.
Is there another way I can share the results of journalctl -b ? I have tried to put it as text in a message like this but that doesn't work either (blank page with error 500 or something like that).

The board doesn't do attachments; there's probably something about it in the FAQ. You can upload it to a pastebin service and link it but people are unlikely to trawl through the whole journal log.
Best bet is to filter it with relevant terms like samba, smb, and net and post it here using code tags.
Code: Select all
journalctl -b | egrep "smb|net"


I never used samba so can't help with your actual problem.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!
User avatar
sunrat
 
Posts: 3424
Joined: 2006-08-29 09:12
Location: Melbourne, Australia

Re: SMB connection fails after changing to usb wifi

Postby Plfeenstra » 2021-02-14 09:51

reinob wrote:In /etc/fstab, make sure you add the "_netdev" option, so that systemd (which nowadays takes care of mounting stuff during boot) recognizes it as requiring the network to be up before mounting.

//192.168.1... cifs _netdev,uid=0,vers=1.0,credentials=/root/.smbcredentials

It (normally) should work, as long as the connection (ethernet or USB wifi) happens during boot (i.e. before you log in as user, etc.).

Good luck,
(and post your "journalctl -b" if you need more help)


Hello,
It seems that I'm stuck in the mud a little :-)
I installed pastebinit and tried to use it to post the journalct -b. But I get an empty paste.debian.net url and warinings that functions are deprecated in python 3.5. I searched for a solution, but didn't find something.
Plfeenstra
 
Posts: 11
Joined: 2021-02-10 08:47

Re: SMB connection fails after changing to usb wifi

Postby Head_on_a_Stick » 2021-02-14 09:54

Plfeenstra wrote:I installed pastebinit and tried to use it to post the journalct -b. But I get an empty paste.debian.net url and warinings that functions are deprecated in python 3.5

https://bugs.debian.org/cgi-bin/bugrepo ... bug=959048

Try this instead:
Code: Select all
journalctl -b | curl -F 'f:1=<-' ix.io
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13317
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: SMB connection fails after changing to usb wifi

Postby Plfeenstra » 2021-02-16 08:32

reinob wrote:In /etc/fstab, make sure you add the "_netdev" option, so that systemd (which nowadays takes care of mounting stuff during boot) recognizes it as requiring the network to be up before mounting.

//192.168.1... cifs _netdev,uid=0,vers=1.0,credentials=/root/.smbcredentials

It (normally) should work, as long as the connection (ethernet or USB wifi) happens during boot (i.e. before you log in as user, etc.).

Good luck,
(and post your "journalctl -b" if you need more help)


Hello,

I returned to fstab to try to mount the share. I have added the _netdev option, but that makes no difference.
The results of the journalctl -b can be found on http://ix.io/2PB5
Thanks in advance.
Plfeenstra
 
Posts: 11
Joined: 2021-02-10 08:47

Next

Return to System configuration

Who is online

Users browsing this forum: No registered users and 13 guests

fashionable