NFS mount on wifi [Solved]

If you are new to Linux or new to Sabayon Linux and just not sure where to post, here ya go. Post without fear of being told to RTFM :-)

Moderator: Moderators

NFS mount on wifi [Solved]

Postby jacob733 » Sun Jul 13, 2014 13:38

Hi

How do I ensure that any NFS mounts defined in fstab does not get mounted until the network connection is up? From the log in journald, I can see that my nfs mount is attempted mounted very early in the boot procedure, and then much later I see that NetworkManager brings up the wifi connection. I also tried to use a cable, but that did not work either. Since this is a laptop, then I would prefer that the wired network is optional that I plug in when I need high throughputs.

When I shut down, I can see that some times the network is torn down before unmount of the file system, causing the shutdown to take a couple of minutes. This is less serious, but it might be related.

What is the procedure to solve this standard problem on Sabayon? It looks like systemd is dependency based, so perhaps there is a dependency I can link to somewhere?

/Jacob
Last edited by jacob733 on Sat Jul 19, 2014 23:01, edited 1 time in total.
jacob733
Baby Hen
 
Posts: 10
Joined: Mon Jul 07, 2014 1:05

Re: NFS mount on wifi

Postby Fitzcarraldo » Sun Jul 13, 2014 16:12

Don't use systemd myself, but you can achieve what you have asked by using NetworkManager Dispatcher. See the following Arch Linux thread for details of what to do (scroll down the posts and you'll see they do precisely what you want to do):

https://bbs.archlinux.org/viewtopic.php?id=151030

The following Arch Linux Wiki article on NetworkManager Dispatcher will also be of interest:

https://wiki.archlinux.org/index.php/Ne ... dispatcher

I use NetworkManager Dispatcher (in OpenRC, not systemd) to delay synchronising my laptop with a remote NTP server until the network connection comes up. You can read about that too if you want, just to give you an idea of the concept even though the commands are different:

http://fitzcarraldoblog.wordpress.com/2 ... me-server/
User avatar
Fitzcarraldo
Sagely Hen
 
Posts: 7984
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom

Re: NFS mount on wifi

Postby jacob733 » Mon Jul 14, 2014 4:36

Thanks, that solves the mount part. But unmount is still problematic.

Does the "down" event get triggered before or after the interface is brought down?

Apart from this, it looks like the systemd shutdown procedure is a bit of a mess. I can see that systemd actually starts the unmount procedure very early, but the wpa_supplicant is shut down shortly after without waiting for unmount to complete. I can also see that dbus is shut down early, but several services complain about missing dbus after this.
jacob733
Baby Hen
 
Posts: 10
Joined: Mon Jul 07, 2014 1:05

Re: NFS mount on wifi

Postby Fitzcarraldo » Mon Jul 14, 2014 16:40

As I wrote, I don't use systemd. (In OpenRC I would stick a Bash script which I'd call something like 01umount.stop in /etc/local.d/ and that would do it.) However, did you try using NetworkManager Dispatcher to do the umounting? If not, have a look at the following Arch Linux thread, which does what you want to do: https://bbs.archlinux.org/viewtopic.php?id=180577. If that doesn't work for you, have a look at a couple of other approaches in another Arch Linux thread: https://bbs.archlinux.org/viewtopic.php?pid=1338249
User avatar
Fitzcarraldo
Sagely Hen
 
Posts: 7984
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom

Re: NFS mount on wifi

Postby jacob733 » Sat Jul 19, 2014 22:23

Yes, I wrote a script for NetworkManager Dispatcher based on the example. But it seems that I need to expand it a bit to account for the possibility of multiple interfaces coming "up" (e.g. if I want to transfer large amounts of data to/from the NAS, I plug in the cable, but if I unplug the cable, NFS gets unmounted). This should not be too hard though by adding some state tracking file in /tmp or something.

I got unmounting to work by adding this line to /usr/lib64/systemd/system/NetworkManager.service in the "Unit" section.

Code: Select all
After=wpa_supplicant.service


When I get the script to work, I think this one is ready to mark as solved,
jacob733
Baby Hen
 
Posts: 10
Joined: Mon Jul 07, 2014 1:05

Re: NFS mount on wifi

Postby jacob733 » Sat Jul 19, 2014 23:01

I got the script to work. Here it is:

Code: Select all
#/bin/sh

IFACE="$1"
STATE="$2"

TMPDIR=/tmp/interfaces_up
MOUNT=/mnt/Data

echo "Interface $IFACE is $STATE"

if [ "$STATE" = "up" ] ; then

   if [[ -z `grep "$MOUNT" /proc/mounts` ]] ; then
      mount "$MOUNT"
   fi
   mkdir -p "$TMPDIR"
   touch "$TMPDIR"/"$IFACE"
elif [ "$STATE" = "down" ] ; then
   if [[ -d "$TMPDIR" ]] ; then
      rm -f "$TMPDIR"/"$IFACE"
      if [[ -z `ls "$TMPDIR"` ]] ; then
         umount "$MOUNT"
         rm -rf "$TMPDIR"
      fi
   fi
fi
jacob733
Baby Hen
 
Posts: 10
Joined: Mon Jul 07, 2014 1:05



Return to Beginners|Newbies Area

Who is online

Users browsing this forum: No registered users and 1 guest