LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-05-2018, 05:17 AM   #1
NDev
LQ Newbie
 
Registered: Apr 2014
Posts: 3

Rep: Reputation: Disabled
Re-mount CIFS share only if not mounted?


Hi,

I have an Ubuntu 16 system that always needs to have a handful of Samba shares mounted.

I put "mount -a" into a cronjob, just in case there was a network problem, and those samba-mounts have been lost/umounted for some network-reason.

But now i noticed, when i excecute just "mount" without any arguments, that those shares are mounted like a hundred times. The output is huge.
Cause everytime "mount -a" is running via cron, its generating new lines there. Making it look as if those shares are mounted plenty of the times in the same way.
It does not seem to make a problem right now. But i could imagine that some buffer or limit will be reached some day with this. And it does not appear to be very clean.

Is there a proper way to do this?
Of course i could do an umount -a , and then mount -a . But this would break connection to those samba shares of course.

Is there no way to re-mount them, just if they are currently NOT mounted?

Regards,
ND

Last edited by NDev; 05-05-2018 at 06:39 AM.
 
Old 05-05-2018, 07:50 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,714

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
You can check to see if the share is still mounted using the mountpoint command although I do not think it would help your network problems since the mount point might be "stale"

Using autofs or systemd automount might help. The shares are automatically unmounted after an idle timeout period and automatically mounted when accessed.

How often do you have network problems?
 
Old 05-07-2018, 01:38 AM   #3
voleg
Member
 
Registered: Oct 2013
Distribution: RedHat CentOS Fedora SuSE
Posts: 354

Rep: Reputation: 51
You should use autofs for CIFS mounts. Linux cannot easy remount CIFS share if windows rebooted and new session should be established.
Here is mine example for SuSE, however it should be exactly the same for you.
Automount CIFS on SLE11SP4
 
Old 05-07-2018, 03:28 PM   #4
NDev
LQ Newbie
 
Registered: Apr 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Ok, Thanks Michaelk and Voleg.
Im gonna give Autofs a try in the weekend.

@voleg: Your Example is well explained, and seems simple / easy to reproduce. I will use it when i try it.
 
Old 05-07-2018, 04:02 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,714

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
While the configuration files will be the same, installing and running autofs are a bit different with Ubuntu.

https://www.itzgeek.com/how-tos/linu...ntu-14-04.html

https://help.ubuntu.com/community/Autofs
 
  


Reply



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
File permissions on samba share mounted on cifs alpha_lt Linux - Software 2 01-23-2018 12:39 AM
[SOLVED] unable to add files to a mounted cifs windows share morganjeff7272 Linux - Networking 2 12-21-2015 04:33 PM
[SOLVED] Mount samba share on Slackware: mount error(6) from mount.cifs frushiyama Slackware 11 01-22-2015 07:12 PM
[SOLVED] CIFS share on old WinNT host - smbclient works, mount -t cifs doesn't Electrode Linux - Networking 4 04-19-2012 09:11 AM
[SOLVED] Where in Fedora's filesystem is that dern CIFS share mounted? szboardstretcher Linux - Software 1 04-26-2011 11:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:00 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration