LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-02-2021, 10:00 AM   #1
Lestrad
Member
 
Registered: Mar 2015
Posts: 43

Rep: Reputation: Disabled
Does Windows disable SMB when it resumes from sleep?


I have a shared directory on my Windows 7 (SP1) box that is mounted on my (Arch) Linux box at boot. Everything works fine until the Windows box goes to sleep and then wakes up. But once it does the share becomes inaccessible on the Linux box with a "cannot access <dir>: Host is down" message. mount shows the share as mounted.

The Windows box is running SMB version 1 and the "autodisconnect" property of LanmanServer is set to -1.

If I try to connect with smbclient -L <hostname> I get a list of all the shares on the Windows box, followed by "SMB1 disabled -- no workgroup available". But as I mentioned, the share mounts and is accessible until the Windows host has gone to sleep and then resumed.

On the Linux side, if I unmount the share and run mount -av, I get:

Code:
mount.cifs kernel mount options: ip=192.168.0.32,unc=\\xxx.xxx.x.xx\<dir>,vers=2.0,user=Dad,pass=********
mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
dmesg shows the following error, presumably from when I tried to remount the share after losing the connection:

Code:
  CIFS: Attempting to mount //xxx.xxx.x.xx/<dir>
    CIFS: VFS: cifs_mount failed w/return code = -2

Is there a way to configure SMB on the Windows side or Samba on the Linux side to avoid losing the connection to the share when the Windows box goes to sleep?

I'd be happy to provide any information anyone might need.

TIA for any help.

Last edited by Lestrad; 07-03-2021 at 02:44 AM.
 
Old 07-03-2021, 12:31 AM   #2
Lestrad
Member
 
Registered: Mar 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
Update by OP

I changed a couple of settings on the Windows side and rebooted Windows, and to my surprise I was still unable to mount the Windows share. The error message was the same:
Code:
mount error(2): No such file or directory
Then I rebooted the Linux box and the share mounted just fine. So the question is now, how can I get Linux to re-establish the connection with the Windows share if it becomes momentarily unavailable?

Last edited by Lestrad; 07-03-2021 at 02:40 AM.
 
Old 07-03-2021, 05:50 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,712

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
I would try using autofs or systemd automount. The connection is only established when you access the share and automatically disconnects after an idle timeout.
 
Old 07-04-2021, 03:08 AM   #4
Lestrad
Member
 
Registered: Mar 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
Thanks for answering.

Quote:
Originally Posted by michaelk View Post
I would try using autofs or systemd automount. The connection is only established when you access the share and automatically disconnects after an idle timeout.
I set up an automount by adding the following line to my fstab:

Code:
//xxx.xxx.x.xx/<dir> /mnt/mountpoint cifs defaults,noauto,user=xxxx,password=xxxxxxxx,x-systemd.automount,x-systemd.requires=network-online.target    0    0
The mountpoint.mount and mountpoint.automount files have been created and the share is mounted and is accessible. But as soon as the Windows host goes to sleep and resumes, the share becomes inaccessible again with the same error messages ("cannot open directory '.': Host is down"). If I do mount -av, the list shows the directory as "Ignored". If I re-start the mountpoint.automount unit, nothing changes.

Do you think it's Windows that's cutting off the connection, or Linux?
 
Old 07-04-2021, 05:49 AM   #5
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,812

Rep: Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141
Any reason for using SMBv1? That may well be impacting here. Try using SMBv2 (Windows 7 is capable of supporting that) and see if this helps. It is a less chatty protocol along with some security improvements.

https://forums.linuxmint.com/viewtopic.php?t=255204
 
Old 07-04-2021, 07:04 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,712

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
You need to specify the idle timeout value. x-systemd.mount-timeout=30 will limit the time the system tries to mount the filesystem.

Code:
//xxx.xxx.x.xx/<dir> /mnt/mountpoint cifs defaults,noauto,x-systemd.automount,x-systemd.mount-timeout=30,x-systemd.idle-timeout=1min,_netdev,user=xxxx,password=xxx 0 0
 
Old 07-04-2021, 11:32 AM   #7
Lestrad
Member
 
Registered: Mar 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
To ferrari: Thanks. I am using SMB2. I've disabled SMB1 on the Windows box.
 
Old 07-04-2021, 12:32 PM   #8
Lestrad
Member
 
Registered: Mar 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
To Michealk:

Thanks again!

At first I thought I had found the problem: I saw somewhere that the Windows host's network adapter needs to be set to "allow system to turn device off to save power" so that when the computer goes to sleep it will be sure to turn it back on. I did that, but after a couple of tests I was getting the same errors.

I copied your entry to fstab, and tried it with and without the above setting. Once or twice, with the network adapter set as above, I was able to connect after Windows resumed. But after waiting a while - maybe 20 minutes - before resuming Windows the share became inaccessible again.

That got me to thinking: does the timeout setting have something to do with it? Is there a way to set it to "no timeout"?

Of course there's one basic question that needs to be answered: Why does the share become accessible again when I reboot the Linux box? What does it do when it reboots? Shouldn't systemd do that when it automounts?
 
Old 07-04-2021, 01:07 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,712

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
The idle timeout is just to automatically un-mount the share if no process is using it on the linux side for that set time. The mount timeout prevents the system from continuously trying to mount the share if it is not accessible. If Windows goes to sleep before before the idle timeout happens it could still hang although I would think a forced un-mount should work without rebooting.

When you reboot your resetting the computer,network and samba connection but your not actually accessing the Windows box until you access that directory. However, I think I read somewhere that if you have created a shortcut in your file browser it could automatically access the share which if the Windows box is sleeping could cause problems. However, mount timeout should prevent the system from hanging completely although I have read that the file browser might hang.

I have not found any related threads that point to a particular samba version but that does not rule it out. It could also be a Windows 7 problem which means you are stuck.
 
Old 07-04-2021, 11:21 PM   #10
Lestrad
Member
 
Registered: Mar 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
The idle timeout is just to automatically un-mount the share if no process is using it on the linux side for that set time. The mount timeout prevents the system from continuously trying to mount the share if it is not accessible. If Windows goes to sleep before before the idle timeout happens it could still hang although I would think a forced un-mount should work without rebooting.

When you reboot your resetting the computer,network and samba connection but your not actually accessing the Windows box until you access that directory. However, I think I read somewhere that if you have created a shortcut in your file browser it could automatically access the share which if the Windows box is sleeping could cause problems. However, mount timeout should prevent the system from hanging completely although I have read that the file browser might hang.

I have not found any related threads that point to a particular samba version but that does not rule it out. It could also be a Windows 7 problem which means you are stuck.
Thanks! No file browser here, this is Arch Linux on a Wandboard, which I access via PuTTY or else via the serial port.

When I get a minute I'm going to try rebooting and then connecting and seeing what the dmesg output is when I connect. Or maybe connect with smbclient verbose and see what that says in order to compare with the errors I get now when I try to connect that way:

Code:
smbclient -L xxx.xxx.x.xx -U Dad -d 256
--------snip---------
SPNEGO login failed: The transport connection has been reset.
session setup failed: NT_STATUS_CONNECTION_RESET
 
Old 08-06-2021, 10:24 AM   #11
Lestrad
Member
 
Registered: Mar 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
The idle timeout is just to automatically un-mount the share if no process is using it on the linux side for that set time. [....]
I have not found any related threads that point to a particular samba version but that does not rule it out. It could also be a Windows 7 problem which means you are stuck.
I've been struggling with this problem for a month and I'm more and more certain it's a Linux problem. After trying many different solutions I've gone back to your original suggestion of setting up automount in fstab (as below):
Code:
//xxx.xxx.x.xx/Work /mnt/Work cifs credentials=/home/alarm/.smbcredentials,vers=2.0,noauto,x-systemd.automount,x-systemd.idle-timeout=1min,x-systemd.mount-timeout=30,_netdev
The share stays mounted and unmounts after one minute, as shown by the systemctl status output on the mnt-Work.mount service. When I ls the mount point it reconnects almost instantaneously. If I put the host PC to sleep and resume, the status shows that it timed out trying to unmount and then unmounted on its own; after I resume it remounts again with no problem.

But if I actually cd to the /mnt/Work directory, it eventually loses the connection. If I ls, I get a
Quote:
"Host is down"
error, and if I try to re-mount the share I get
Quote:
"No such file or directory."
The systemctl status says:
Code:
Warning: The unit file, source configuration file or drop-ins of mnt-Work.mount changed on disk. Run 'systemctl daemon-reload' to reload units.
but if I do the daemon-reload nothing changes. Only after rebooting the Linux box can I connect to the share again.

So it looks to me as if actually being in the mount point of the share is what's causing the problem. But moving to another directory doesn't help. Rebooting is the only thing that works.

It appears to me that the CIFS VFS has been told the host is down and for some reason won't try to reconnect. Watching the network activity shows no SMB2 calls being made to the Windows host.

I'd love to hear what you think.
TIA
Les
 
Old 08-28-2021, 01:02 AM   #12
Lestrad
Member
 
Registered: Mar 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
Hello?
 
Old 08-28-2021, 02:43 AM   #13
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,812

Rep: Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141
Quote:
Originally Posted by Lestrad View Post
...but if I do the daemon-reload nothing changes. Only after rebooting the Linux box can I connect to the share again.
Does the following work in this situation?
Code:
sudo systemctl daemon-reload
sudo systemctl restart remote-fs.target
 
Old 08-28-2021, 03:03 AM   #14
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,812

Rep: Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141Reputation: 1141
I note that you posted to superuser.com regarding this...
https://superuser.com/questions/1660...with-smbclient

This might be helpful to you regarding NIC power management (Windows 7 server)...

https://docs.microsoft.com/en-us/tro...etwork-adapter
 
Old 08-28-2021, 03:12 AM   #15
Lestrad
Member
 
Registered: Mar 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ferrari View Post
I note that you posted to superuser.com regarding this...
https://superuser.com/questions/1660...with-smbclient

This might be helpful to you regarding NIC power management (Windows 7 server)...

https://docs.microsoft.com/en-us/tro...etwork-adapter
Hello. I've cd'd into the mount directory of the share and am waiting for it to disconnect. As for the NIC, I doubt if that has anything to do with it since I can always connect using SMBCLIENT.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
screen always starts/resumes at minimum brightness gbloon Linux - Laptop and Netbook 2 01-13-2009 01:13 PM
LXer: Ridiculous Resumes - Unix, Linux and everything in between LXer Syndicated Linux News 3 10-26-2008 08:41 AM
system freezes then resumes after fglrx and kernel update cougar618 Fedora 6 09-26-2008 12:37 AM
Hibernation resumes to wrong resolution organica Linux - Laptop and Netbook 1 03-26-2007 08:40 PM
ACPI Resumes to runlevel 0 instead of 3 jayhel Slackware 4 05-30-2006 11:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration