Handling network mounts on a very mobile laptop?
Posted by geekneck on Thu 5 Nov 2009 at 06:43
I have a laptop that travels with me to work as well as being used at home. I have a number of network CIFS mounts that I like to have available when I am at home, so I have them set to "auto" in /etc/fstab. When I am at work, I use a Mobile Broadband card to connect to the Internet. When at home, I typically use Ethernet.
The problem is that when I shift locations, I need proper handling of those network mounts. Typically, I will suspend my laptop at home, come into work the next day, and resume the laptop with the Broadband card. The problem is that I am now on a different network, and those CIFS shares are no longer available, causing most operations to hang. I typically have to hard restart the laptop in order to gain proper functionality.
I have tried using noauto in /etc/fstab, but then I have to manually connect the CIFS shares at home. I still have to remember to manually disconnect them before suspending at night.
I would think this is not an uncommon usage scenario. Does anyone have any insights as to handle this seamlessly? Thanks in advance!
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
See http://www.debian.org/doc/manuals/debian-reference/ch05.en.html (sections 5.3 and up) for more information.
[ Parent | Reply to this comment ]
My personal mounting script ;-) uses "up" mount some of the entries inside /etc/fstab. Because I use DHCP, I can scan the domain within the script. My fstab comes with mount pathes, which include the domain! So I'm able grep all mounts only with this string.
Another possible way is the usage of arping. Here you can ping a server and use the MAC address to decide with mount should be used.
At last, you can use iwconfig to exrect the ESSID.
Nevertheless, using NetworkManager gives you a "per user" way to mount stuff.
By the way: if you are interessed in my script, drop me an mail...
[ Parent | Reply to this comment ]
The only difference is that i have wifi on both home and work and i use wicd as network manager on ubuntu. with wicd there is no need to manually edit scripts, each network can have couple of pre/post scripts and since i use wifi, it works almost seamlessly!
I mount CIFS shares on post connection and unmount them on pre disconnect.
You can have similar config on wired networks, give it a try: http://wicd.sourceforge.net/
[ Parent | Reply to this comment ]
The only difference is that i have wifi on both home and work and i use wicd as network manager on ubuntu. with wicd there is no need to manually edit scripts, each network can have couple of pre/post scripts and since i use wifi, it works almost seamlessly!
I mount CIFS shares on post connection and unmount them on pre disconnect.
You can have similar config on wired networks, give it a try: http://wicd.sourceforge.net/
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
(tested only for ssh, but i suppose it will work for other connections as well; in a setup like yours, using sshfs provides an advantage because it can use an sshconfig dispatch to figure out how to establish the connection based on where you are)
i suppose you need "proper" file system support, which is provided by gvfs-fuse. as opposed to the old gnome-vfs, gvfs has no gnome/x11 dependencies any more.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
So pointers:
Create a bash script.
It must detect what connection interface we are using..
If it has changed then unmount the server (if already mounted) then re-mount.
Use /etc/cron.d/hourly to run it..
Don't suspend: it's not always reliable and can be annoying when you have a low battery.
Debian-Squeeze is faster and when released I'd recommend updating, use kfreebsd version so you can use zfs, and also dont forget to backup everything you need then install to a new partition to test it out then if you like it backup your old install and have fun reinstalling the new version and getting everything you need there too, then keep the backup there so you can boot it when you need it, you could also put a live DVD iso there to boot. :) always easy to recover if you need to..
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]