Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

SMB connection fails after changing to usb wifi

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
Plfeenstra
Posts: 11
Joined: 2021-02-10 08:47

SMB connection fails after changing to usb wifi

#1 Post by Plfeenstra »

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.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: SMB connection fails after changing to usb wifi

#2 Post by Head_on_a_Stick »

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.
deadbang

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

Re: SMB connection fails after changing to usb wifi

#3 Post by Plfeenstra »

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

#4 Post by Plfeenstra »

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

reinob
Posts: 1196
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: SMB connection fails after changing to usb wifi

#5 Post by reinob »

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.

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

Re: SMB connection fails after changing to usb wifi

#6 Post by Plfeenstra »

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.

reinob
Posts: 1196
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: SMB connection fails after changing to usb wifi

#7 Post by reinob »

@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, ??

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

Re: SMB connection fails after changing to usb wifi

#8 Post by Plfeenstra »

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

#9 Post by Plfeenstra »

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 ;-)

reinob
Posts: 1196
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: SMB connection fails after changing to usb wifi

#10 Post by reinob »

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)

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

Re: SMB connection fails after changing to usb wifi

#11 Post by Plfeenstra »

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

User avatar
sunrat
Administrator
Administrator
Posts: 6476
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 118 times
Been thanked: 474 times

Re: SMB connection fails after changing to usb wifi

#12 Post by sunrat »

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!

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

Re: SMB connection fails after changing to usb wifi

#13 Post by Plfeenstra »

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.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: SMB connection fails after changing to usb wifi

#14 Post by Head_on_a_Stick »

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
deadbang

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

Re: SMB connection fails after changing to usb wifi

#15 Post by Plfeenstra »

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.

reinob
Posts: 1196
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: SMB connection fails after changing to usb wifi

#16 Post by reinob »

Thanks @Plfeenstra,

From the looks of it your USB-WIFI connection is being managed by NetworkManager, but only when you are logged on!

Before you login, systemd has already failed to mount the share, as on the one hand it thinks you are online ("Reached target Network is Online"), but Network Manager seems to need time to think and/or who-knows-what that it only manages to connect when you are logged on.

I don't know much about Network Manager, and I would not recommend it for computers that are always online. All you need is wpa_supplicant and systemd-networkd. Oddly, https://wiki.debian.org/WiFi/HowToUse does not even care to explain how to use networkd.

Here (https://hackaday.io/project/162164/instructions) it is more or less well-explained. Let me know if you have problems.

reinob
Posts: 1196
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: SMB connection fails after changing to usb wifi

#17 Post by reinob »

I googled a bit about NetworkManager and it seems (thanks for the excellent Arch wiki: https://wiki.archlinux.org/index.php/NetworkManager) that it will only connect when a user has logged on, which for your use-case is absurd.
Connect to network with secret on boot

By default, NetworkManager will not connect to networks requiring a secret automatically on boot. This is because it locks such connections to the user who makes it by default, only connecting after they have logged in. To change this, do the following:
  • 1. Right click on the nm-applet icon in your panel and select Edit Connections and open the Wireless tab
    2. Select the connection you want to work with and click the Edit button
    3. Check the boxes “Connect Automatically” and “Available to all users”
    4. Additionally, ensure that under "Wi-Fi Security", "Store password for all users (not encrypted)" is selected
Log out and log back in to complete.
So make sure that the connection is marked as "available to all users."

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: SMB connection fails after changing to usb wifi

#18 Post by Head_on_a_Stick »

reinob wrote:All you need is wpa_supplicant and systemd-networkd. Oddly, https://wiki.debian.org/WiFi/HowToUse does not even care to explain how to use networkd.
There is a systemd-networkd page in the Debian wiki but it only deals with servers. The ArchWiki page is applicable to Debian though and that isn't riddled with ads & javascript like that atrocious "hackaday" [sic] site :mrgreen:
deadbang

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

Re: SMB connection fails after changing to usb wifi

#19 Post by Plfeenstra »

Thanks a lot for your replies! I learned a lot. I will try the solution for the networkmanager this weekend and let you know how I proceed.


P

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

Re: SMB connection fails after changing to usb wifi

#20 Post by Plfeenstra »

reinob wrote:I googled a bit about NetworkManager and it seems (thanks for the excellent Arch wiki: https://wiki.archlinux.org/index.php/NetworkManager) that it will only connect when a user has logged on, which for your use-case is absurd.
Connect to network with secret on boot

By default, NetworkManager will not connect to networks requiring a secret automatically on boot. This is because it locks such connections to the user who makes it by default, only connecting after they have logged in. To change this, do the following:
  • 1. Right click on the nm-applet icon in your panel and select Edit Connections and open the Wireless tab
    2. Select the connection you want to work with and click the Edit button
    3. Check the boxes “Connect Automatically” and “Available to all users”
    4. Additionally, ensure that under "Wi-Fi Security", "Store password for all users (not encrypted)" is selected
Log out and log back in to complete.
So make sure that the connection is marked as "available to all users."
Thank you very much, this solution works perfect for me!
I will study the journalctl -b results; I think I can learn a lot from that. :)

Peter

Post Reply