Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have several notebooks running Scientific Linux 6.3.

The suspend function is working quite well, except for one problem:

When a notebook mounts a Samba share, plays a few videos through this share then the suspend function stops working, and the notebook suddenly needs 5 minutes to suspend.

Again, this problem only occurs if they watched videos over the samba share.

QUESTION: WHY? does samba keeps something open and need a timeout of 5 minutes, just after the suspend function has been involved or what?

Any suggestions on where to look to find out what's going on would be appreciated. Or a way for I could write a bash script to check when is the suspend button pressed so that I could do xy* thing to the machine.

(*xy=anything that corrects this problem)

share|improve this question
    
Just to clarify, if a notebook mounts the samba share, are any of the other notebooks affected in that way? IE, the ones that don't have the share mounted, or didn't play any videos from it yet? –  Shadur Jul 17 '12 at 11:25
    
no, the samba share is on an openwrt router.. the notebooks doesn't affect each other –  gasko peter Jul 18 '12 at 20:07
    
can you post some logs which may relate to suspend (dmesg | grep -P (s2ram|suspend), possibly more)? –  Jonas Wielicki Jul 19 '12 at 14:20
    
5 Minutes sounds like Kerberos timeout. How do you authenticate? –  Nils Jul 24 '12 at 20:10

2 Answers 2

I made the experience that samba shares react pretty bad if the connection gets interrupted while they're mounted.

Possibly the network is going down before the storage, so it may be that your system is trying to do anything with the samba share which is not possible without network connection. A workaround would be to auto-unmount it on suspend (and maybe remount it afterwards):

#!/bin/bash
if [ $1 == "suspend" ]; then
    umount -afl -t cifs
fi

If you place that in /etc/pm/sleep.d/ and make it executable, it should execute upon every suspend. I cannot really test though if it happens soon enough, just give feedback in the comments. However, you'll have problems if programs are still accessing the files in the share. -l should still unmount it from the filesystem tree, -f will make sure it works when the share server is not reachable.

You could extend that to be stateful and (attempt to) restore your mounts on resume.

I was unable to find official sources. The best is possibly to check out the linux kernel source and see in which order devices are sent to suspend and look what cifs tries to do upon suspend and so on.

share|improve this answer
    
I will try this one out as soon as I can get close to the machines.. thanks! (I will post the resolution here) –  gasko peter Jul 28 '12 at 19:44
up vote 0 down vote accepted

1)

configure sudo permissions:

visudo
USERNAME ALL = NOPASSWD: /bin/mount //192.168.1.1/Share /home/USERNAME/Desktop/Share -t cifs*
USERNAME ALL = NOPASSWD: /bin/umount -f -a -t cifs
USERNAME ALL = NOPASSWD: /bin/umount -f -l -a -t cifs
USERNAME ALL = NOPASSWD: /sbin/modprobe -r -f cifs

======================================================================
2)

with normal user:

vi ~/.mountsamba.sh; chmod +x ~/.mountsamba.sh
#!/bin/bash
case $1 in

mount)
echo 'In progress...'
/usr/bin/sudo /bin/mount //192.168.1.1/Share /home/USERNAME/Desktop/Share -t cifs -o ro,bg,intr,soft,noexec,nosuid,nodev,password=,nolock
pkill nautilus
echo "MOUNTShare - `date`" | /usr/bin/logger
;;

umount)
echo 'folyamatban...'
/usr/bin/sudo /bin/umount -f -a -t cifs
/usr/bin/sudo /bin/umount -f -l -a -t cifs
sleep 5
/usr/bin/sudo /sbin/modprobe -r -f cifs
pkill nautilus
echo "UMOUNTShare - `date`" | /usr/bin/logger
;;

*)
exit 1
;;

esac

======================================================================
3)

put icon in GNOME-panel:

gnome-terminal -x bash -c "/home/USERNAME/.mountsamba.sh mount"
gnome-terminal -x bash -c "/home/USERNAME/.mountsamba.sh umount"

======================================================================
4)

if you want to use autofs:

vi /etc/auto.master
/-  /etc/auto.samba --timeout=120

vi /etc/auto.samba
/home/USERNAME/Desktop/Share    -fstype=cifs,bg,intr,soft,ro,noexec,nosuid,nodev,password=,nolock   ://192.168.1.1/Share
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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