Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mounting/unmounting NFS volumes based on current network
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
passive
Tux's lil' helper
Tux's lil' helper


Joined: 31 Dec 2004
Posts: 105

PostPosted: Fri Feb 08, 2008 5:09 pm    Post subject: mounting/unmounting NFS volumes based on current network Reply with quote

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


Joined: 22 Feb 2004
Posts: 212
Location: Toronto, Canada

PostPosted: Fri Feb 08, 2008 6:17 pm    Post subject: Reply with quote

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


Joined: 31 Dec 2004
Posts: 105

PostPosted: Sat Feb 09, 2008 4:15 pm    Post subject: Reply with quote

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


Joined: 06 Mar 2007
Posts: 23103

PostPosted: Sat Feb 09, 2008 10:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security 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