Auto mount Windows shares
I have a Windows Server 2008 file server with a few network shares configured, and I'm having problems finding a good stable way to mount them using linux clients. The clients all use Debian; one Squeeze and a few Wheezy.
Up until now I've been using the following to manually mount each share: Code:
mount -t cifs //<server>/<share> <mount dir> -o username=<username>,password=<password> Another issue I've been having is that sometimes, when the share has been mounted for a long time (a day or two) or if it's been in sleep mode for a while, the mount 'stops responding'; if you run a ls command in the mounted directory it just gets stuck and you have to abort it with Ctrl-C. When this happens not even the umount command works, nor can I remount the share. Normally I'm then forced to reboot it before I can get it to work again. This latter problem has only occured on clients connected over wireless network so that may play a part in it I suppose. So, what I'm looking for is basically the "right" way to set up a persistent mount, kind of the way Windows does its "Map network drive". Is it possible to have it automatically mount on startup? What happens if the wireless network is a bit slow to connect, can you somehow make it *wait* for a connected network interface before mounting the drive? |
To automatically mount something at boot, put the relevant information in /etc/fstab and add the auto option, like this:
Code:
//<server>/<share> <mount dir> cifs username=<username>,password=<password>,auto 0 0 |
I would suggest you to use automounter, it will also unmount if the drive was not used for a while.
The problem cannot be solved, an unavailable share will always cause such troubles (you must umount before disconnect) |
Quote:
|
Quote:
Quote:
Code:
mount -a Code:
mount -a -t cifs |
Thanks for the explanations!
I tried using the line specified by 414N above in fstab and mounting the shares worked beautifully on all my clients, so thanks for that! Something a bit odd though, on my laptop the share doesn't seem to get unmounted properly before reboot, it still gets stuck on "Stopping rsyslogd" when rebooting. Works if I manually use the umount command before rebooting. The laptop runs Debian Wheezy with X installed. On my other Debian client it does, however, get unmounted correctly using the exact same fstab line, which runs Squeeze backports without X and connected over Ethernet. Any ideas? |
I suppose this should be handled by your distribution service scripts.
In Slackware there is a specific phase during system shutdown which makes sure that all NFS (it should be trivial to use it for cifs/smbfs too) mounts are unmounted and, if there's a process still keeping a file open on them, it is killed: Code:
# Kill any processes (typically gam) that would otherwise prevent |
I did a bit of digging and found the 'debian way' to do it. It's a shutdown script called umountnfs.sh and after a adding a few well-placed echo statements I found that the script hangs running the following command, right at the end of this script (/mnt/server is where I have the share mounted):
Code:
fstab-decode umount -f -l /mnt/server |
All times are GMT -5. The time now is 09:53 AM. |