View previous topic :: View next topic |
Author |
Message |
passive Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
Joined: 31 Dec 2004 Posts: 105
|
Posted: Fri Feb 08, 2008 5:09 pm Post subject: mounting/unmounting NFS volumes based on current network |
|
|
Hi All,
This is something I've wanted to have working for a while, but never bothered to ask here yet.
Is there a simple way of mounting an NFS volume as soon as I connect to a specific network? I would also like to unmount it automatically when I disconnect from that network.
In my case, I have a server at home where I store most of my media, and I would like to mount volumes off it automatically whenever I'm at home. I use a wireless network, so that might complicate things.
Thanks. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
thepustule Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/69280609544577fbd6ffe8.jpg)
Joined: 22 Feb 2004 Posts: 212 Location: Toronto, Canada
|
Posted: Fri Feb 08, 2008 6:17 pm Post subject: |
|
|
Have you considered using autofs?
The difference is that autofs will only try to mount when you access the volume. You can configure it to autodismount after a specified inactivity period. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
passive Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
Joined: 31 Dec 2004 Posts: 105
|
Posted: Sat Feb 09, 2008 4:15 pm Post subject: |
|
|
I recall looking at autofs briefly in the past. I suppose my main concern with it is that I have a few programs that attempt to access the shared volume automatically (Amarok, for example), and I would rather it just be an empty folder, rather than autofs first attempting to mount it. Any idea if autofs can be configured to fail gracefully in this kind of situation. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23103
|
Posted: Sat Feb 09, 2008 10:17 pm Post subject: |
|
|
Autofs can run a script to determine what mounts are available. This is usually used to automatically discover the available exports on the NFS server. You could use it for this purpose as well: Code: |
if computer_at_home; then
autodiscover_home_NFS_mounts
elif computer_at_wireless; then
autodiscover_wireless_NFS_mounts
fi |
Add additional branches as appropriate. If you do not want any mounts available when you are on wireless, make that block just exit. You will need to implement computer_at_home and computer_at_wireless in a way that they correctly recognize those scenarios. Without knowing more about your network topology, I can only guess at possible implementations. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|