13

I have a problem with a bunch of CIFS mounts that look like this:

//192.168.10.2/remote-share /home/windows-shared/remote-share cifs defaults,user=xxx,password=xxx,uid=603,gid=603       0 0

This issue occurs after a while, usually after a day when the users boot their machines in the morning and their shares don't work remotely any more.

So when I try to do a ls I get this:

ls: cannot access /home/windows-shared/remote-share: Host is down

I get nothing related in dmesg. The problem with this is that now any read call to this part of the system just hangs so as a solution I would rather have a faster error rather than hanging indefinitely.

After reading a bit the man page of mount.cifs it appears that by default every mount is soft meaning that it would timeout eventually. The problem is that it takes a way too long to timeout.

Update:

Adding these parameters to the mount command didn't help either:

soft,timeo=300,retrans=3
  • Have you tried using timeo=n and retrans=m to shorten the timeout interval? – MadHatter Mar 12 '14 at 9:41
  • @MadHatter Trying it now. I'll see if this works. Thanks. – Alexandru Plugaru Mar 12 '14 at 9:52
  • @MadHatter adding those params doesn't really change anything – Alexandru Plugaru Mar 13 '14 at 9:22
  • What do you mean by "doesn't change anything"; could you be a bit more quantitative, and maybe descriptive, too? – MadHatter Mar 13 '14 at 14:05
  • @MadHatter by doesn't change anything I mean that the changes you suggested didn't improve the situation. I specify, adding those parameters didn't improve or worsen the issue. Any file call still hangs the process. – Alexandru Plugaru Mar 13 '14 at 15:39
1

I would highly suggest AutoFS.

This will dynamically mount and unmount your network shares in the background, all transparent to the user. I used to have problems with unmounting and remounting mobile devices until I made the switch.

Unfortunately, there are far too many guides which overly complicate autofs setup. Assuming you're on an Ubuntu box, here are the easy instructions on setting it up.

Here's some very simple instructions:

  • Install from apt-get: sudo apt-get install autofs -y
  • Remove everything in /etc/auto.master and replace with: /- /etc/auto.cifs --timeout=20 --ghost
  • Add one line like this to auto.cifs for each mount:/mnt/LOCAL/MOUNT/PATH -fstype=cifs,rw,noperm,credentials=/etc/auto.credentials ://SERVER/MOUNT
  • In /etc/auto.credentials, add the following content: username=USERNAME password=PASSWORD
  • Finally, sudo service autofs restart.

That's it.

  • 1
    How is this supposed to fix a hanging current connection? – Sven Aug 10 '17 at 15:23
  • It doesn't. You adjust your mount settings once to use autofs, and you stop getting hung connections, in most cases. It should fix the problem, not the symptom. – Ben Yanke Aug 10 '17 at 16:28
0

In most cases, you can at least remove the hanging mountpoint by doing a lazy unmount: umount -l //server/share. Maybe you can put that into a suspend hook (as I understand it, your machines are suspended at night and run for multiple days?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.