Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
nfs and suspend2ram
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
morpheus2051
Tux's lil' helper
Tux's lil' helper


Joined: 07 May 2006
Posts: 93

PostPosted: Sat Sep 15, 2012 10:30 am    Post subject: nfs and suspend2ram Reply with quote

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
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 2289
Location: Canada

PostPosted: Sat Sep 15, 2012 4:35 pm    Post subject: Re: nfs and suspend2ram Reply with quote

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
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 2289
Location: Canada

PostPosted: Sat Sep 15, 2012 4:38 pm    Post subject: Reply with quote

Or as a first debug test, if you run the script manually, does it unmount all your nfs partitions ?
Back to top
View user's profile Send private message
Helmering
n00b
n00b


Joined: 13 Dec 2011
Posts: 39
Location: Italy

PostPosted: Sat Sep 15, 2012 8:05 pm    Post subject: Re: nfs and suspend2ram Reply with quote

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 =>
Code:
chmod 755


Bye
Back to top
View user's profile Send private message
morpheus2051
Tux's lil' helper
Tux's lil' helper


Joined: 07 May 2006
Posts: 93

PostPosted: Sun Sep 16, 2012 7:35 am    Post subject: Reply with quote

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
View user's profile Send private message
morpheus2051
Tux's lil' helper
Tux's lil' helper


Joined: 07 May 2006
Posts: 93

PostPosted: Thu Sep 27, 2012 4:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum