mount by network location

/etc/fstab:

1
host.lan:/ /media/mount nfs4 _netdev,noauto,users,async 0 0

/usr/local/bin/network-mount:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
stasjon=/media/mount
ping=`/usr/bin/fping -q host.lan`
if [ $? = 0 ]; then
  mountpoint $stasjon > /dev/null
  if [ $? != 0 ]
    then mount $stasjon
  fi
  else
  mountpoint $stasjon > /dev/null
  if [ $? = 0 ]
    then umount -l $stasjon
  fi
fi

chmod +x /usr/local/bin/network-mount
crontab -e

1
* * * * * /usr/local/bin/network-mount

Tags:

One Response to “mount by network location”

  1. Timeout never ending command « blog.seljebu.no Says:

    [...] never times out by itself. I had this problem with mounting NFS, and when doing it automagically(mount by network location), you get thousands of mount.nfs never timing [...]

Leave a Reply