LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 09-24-2012, 07:40 AM   #1
yzfr1
LQ Newbie
 
Registered: Apr 2012
Distribution: Debian Wheezy
Posts: 17

Rep: Reputation: Disabled
Question 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>
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?
 
Old 09-24-2012, 08:18 AM   #2
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 608

Rep: Reputation: 179Reputation: 179
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'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.
 
1 members found this post helpful.
Old 09-24-2012, 08:28 AM   #3
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,506

Rep: Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221
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)
 
Old 09-24-2012, 08:29 AM   #4
yzfr1
LQ Newbie
 
Registered: Apr 2012
Distribution: Debian Wheezy
Posts: 17

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by 414N View Post
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'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?
 
Old 09-24-2012, 10:29 AM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Gentoo
Posts: 15,437
Blog Entries: 2

Rep: Reputation: 4000Reputation: 4000Reputation: 4000Reputation: 4000Reputation: 4000Reputation: 4000Reputation: 4000Reputation: 4000Reputation: 4000Reputation: 4000Reputation: 4000
Quote:
Originally Posted by yzfr1 View Post
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?
Usually the boot process should wait until the network connection is established when network is available.
Quote:
Is there a command to *refresh* fstab if you want it to reattempt the mounting at a later time?
Yes, you can use the mount command for that. For example,
Code:
mount -a
will try to mount everything it finds in /etc/fstab, maybe with complaining if something is already mounted. You can also use
Code:
mount -a -t cifs
to only mount those entries in fstab that have the filesystem declared as cifs.
 
1 members found this post helpful.
Old 09-24-2012, 10:43 AM   #6
yzfr1
LQ Newbie
 
Registered: Apr 2012
Distribution: Debian Wheezy
Posts: 17

Original Poster
Rep: Reputation: Disabled
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?
 
Old 09-24-2012, 10:53 AM   #7
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 608

Rep: Reputation: 179Reputation: 179
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
# unmounting NFS volumes:
unset FUSER_DELAY
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 &
  FUSER_DELAY=5
done
# If fuser was run, let it have some delay:
if [ ! -z "$FUSER_DELAY" ]; then
  sleep $FUSER_DELAY
fi

# 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
 
Old 09-25-2012, 06:13 AM   #8
yzfr1
LQ Newbie
 
Registered: Apr 2012
Distribution: Debian Wheezy
Posts: 17

Original Poster
Rep: Reputation: Disabled
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
The strange thing though is that the command is identical to that being run on my Debian Squeeze machine, but on that it works..

Last edited by yzfr1; 09-25-2012 at 09:19 AM.
 
  


Reply

Tags
debian, mount, network, persistent, share


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do I have to have static IP assignment to auto-mount Samba shares? buccaneere Linux - Networking 1 03-31-2009 12:29 PM
Windows shares - auto mount problem hopmedic Linux - Networking 4 02-07-2004 10:14 PM
auto mount shares before login Archer12 Linux - Networking 2 01-13-2004 07:05 PM
Linux can mount samba shares but not windows shares bindsocket Linux - Software 1 12-01-2003 05:28 PM
Auto Mount On Boot Win32 Shares zipur Linux - Networking 1 10-08-2002 02:38 AM


All times are GMT -5. The time now is 12:02 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration