Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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:
mount -t cifs //<server>/<share> <mount dir> -o username=<username>,password=<password>
That works for the moment, but not as well as I'd like. The first issue is that when forgetting to unmount the share before shutdown/reboot the shutdown procedure gets stuck for a really long time on "Stopping rsyslogd". It gets shut down eventually, but may take up to 10-15 minutes at times.
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?
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)
I've got no Debian knowledge whatsoever, so I guess you'll have to wait for some Debian-expert to jump in to have your other answers.
Thanks for your answer mate. Generally speaking, if it takes a few seconds to establish the network connection (due to, for example, a slow wifi router), will this still work? Is there a command to *refresh* fstab if you want it to reattempt the mounting at a later time?
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.
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:
# Kill any processes (typically gam) that would otherwise prevent
# unmounting NFS volumes:
for dir in $(/bin/mount | grep 'type nfs' | cut -d ' ' -f 3 ) ; do
echo "Killing processes holding NFS mount $dir open..."
# Background this to prevent fuser from also blocking shutdown:
/usr/bin/fuser -k -m $dir &
# If fuser was run, let it have some delay:
if [ ! -z "$FUSER_DELAY" ]; then
# Unmount any NFS, SMB, or CIFS filesystems:
echo "Unmounting remote filesystems."
/bin/umount -v -a -l -f -r -t nfs,smbfs,cifs
Maybe you can add something similar to your shutdown scripts, if there's not already a more Debian-ish way to do it
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):
fstab-decode umount -f -l /mnt/server
The strange thing though is that the command is identical to that being run on my Debian Squeeze machine, but on that it works..