View previous topic :: View next topic |
Author |
Message |
morpheus2051 Tux's lil' helper
Joined: 07 May 2006 Posts: 95
|
Posted: Sat Sep 15, 2012 10:30 am Post subject: nfs and suspend2ram |
|
|
Hello,
I have a nfs server to which I connect with my laptop. Sometimes I forget to umount $nfs when I suspend my laptop. Now when I resume my laptop, which is running stable kde4, I cannot login to my session anymore because the nfs-mount stalls. df dos not work, either. So I put the following script in /etc/pm/sleep.d/00umountnfs:
Code: | #!/bin/bash
case "$1" in
hibernate|suspend)
for nfs in $(/bin/mount -t nfs | /usr/bin/awk {'print $3'}) ; do
/bin/umount -fl $nfs
done
for cifs in $(/bin/mount -t cifs | /usr/bin/awk {'print $3'}) ; do
/bin/umount -fl $cifs
done
;;
thaw|resume)
exit 0
;;
*)
exit 0
;;
esac
|
pm-suspend.log says the script is run but the nfs-mount is at resume still mounted and thus I cannot login to my kde-session. How do you guys solve this problem? Any help is appreciated. Thanks in advance.
morpheus |
|
Back to top |
|
|
dmpogo Advocate
Joined: 02 Sep 2004 Posts: 3267 Location: Canada
|
Posted: Sat Sep 15, 2012 4:35 pm Post subject: Re: nfs and suspend2ram |
|
|
morpheus2051 wrote: | Hello,
I have a nfs server to which I connect with my laptop. Sometimes I forget to umount $nfs when I suspend my laptop. Now when I resume my laptop, which is running stable kde4, I cannot login to my session anymore because the nfs-mount stalls. df dos not work, either. So I put the following script in /etc/pm/sleep.d/00umountnfs:
Code: | #!/bin/bash
case "$1" in
hibernate|suspend)
for nfs in $(/bin/mount -t nfs | /usr/bin/awk {'print $3'}) ; do
/bin/umount -fl $nfs
done
for cifs in $(/bin/mount -t cifs | /usr/bin/awk {'print $3'}) ; do
/bin/umount -fl $cifs
done
;;
thaw|resume)
exit 0
;;
*)
exit 0
;;
esac
|
pm-suspend.log says the script is run but the nfs-mount is at resume still mounted and thus I cannot login to my kde-session. How do you guys solve this problem? Any help is appreciated. Thanks in advance.
morpheus |
Perhaps it does not have a time to unmount. Put some logic to check that umount has succeeded |
|
Back to top |
|
|
dmpogo Advocate
Joined: 02 Sep 2004 Posts: 3267 Location: Canada
|
Posted: Sat Sep 15, 2012 4:38 pm Post subject: |
|
|
Or as a first debug test, if you run the script manually, does it unmount all your nfs partitions ? |
|
Back to top |
|
|
Helmering n00b
Joined: 13 Dec 2011 Posts: 63 Location: Italy
|
Posted: Sat Sep 15, 2012 8:05 pm Post subject: Re: nfs and suspend2ram |
|
|
I'm using this script in /etc/pm/sleep.d/06_nfs, it's similar to yours and it's working fine.
Code: |
#!/bin/bash
#
# Unmount NFS file systems before suspending, to
# prevent hangup when the system resume and NFS
# is not there.
#
# By Ralf, Unmount NFS http://palebluedot.nl/jml/computer-stuff/3-linux/26-umountnfs.html
case "$1" in
hibernate|suspend)
{
for fs in $(/bin/mount -t nfs | /usr/bin/awk {'print $3'}) ; do
echo "unmounting $fs";
/bin/umount -fl $fs;
done
} 2>/dev/null
;;
# do nothing when resuming
thaw|resume)
{
echo "Nothing to do with NFS"; } 2>/dev/null
;;
*)
;;
esac
exit $?
|
Script must be executable =>
Bye |
|
Back to top |
|
|
morpheus2051 Tux's lil' helper
Joined: 07 May 2006 Posts: 95
|
Posted: Sun Sep 16, 2012 7:35 am Post subject: |
|
|
The script does what it should do. It is executable, too. I will modify it a bit and rename it. Perhaps the order of execution is not right.
Is it normal that I can't login into kde when a nfs-mount stalls? I have tested to shutdown the nfs server while the share was still mounted on my laptop. kde stalls and is not usable anymore. This is not the desired behavior, or is it? |
|
Back to top |
|
|
morpheus2051 Tux's lil' helper
Joined: 07 May 2006 Posts: 95
|
Posted: Thu Sep 27, 2012 4:08 pm Post subject: |
|
|
I want to share my improved script with you. Now it logs what it does. On one of my machines it works without a hitch. On the other machine it successfully unmounts any mounted nfs-mount but my kde on that machine is still acting up. I have to investigate on that.
But here is the script:
Code: | #!/bin/sh
. "${PM_FUNCTIONS}"
case "$1" in
hibernate|suspend)
for nfs in $(/bin/mount -t nfs | /usr/bin/awk {'print $3'}) ; do
printf "umount %s..." "$nfs"
/bin/umount -fl $nfs && echo Done. || echo Failed.
done
for cifs in $(/bin/mount -t cifs | /usr/bin/awk {'print $3'}) ; do
printf "umount %s..." "$cifs"
/bin/umount -fl $cifs && echo Done. || echo Failed.
done
;;
thaw|resume)
exit 0
;;
*)
exit 0
;;
esac
exit $?
|
|
|
Back to top |
|
|
|