Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
32
rated 0 times [  32] [ 0]  / answers: 1 / hits: 36479  / 3 Years ago, sun, june 20, 2021, 12:25:01

I am trying setup permanent samba share mounts. That's not too hard using these instructions. But, I want them to




  1. Automatically remount whenever I join the network where these shares are available.

  2. Automatically unmount (or make access requests fail immediately instead of hanging) whenever I leave the network, i.e. avoid this automatically.



Googling suggests that AutoFS might be helpful. I gather it takes care of the 1. above but I am not sure about the 2.



The other questions about automated Samba mounts, i.e. How to mount a samba share permanently?, do not seem to address automatic remounts/unmounts, so I think this is not a duplicate.



Thanks.


More From » mount

 Answers
5

Mounting Samba shares with CIFS:



Edit your /etc/fstab file to automatically mount your Samba shares:



//<server>/<share> <mount point> cifs rw,_netdev,user=<username>,password=<password>,uid=<uid>,gid=<gid> 0 0


Notice the _netdev option:



CIFS doesn't know about this option and will throw a warning about it, but you should leave it in.



This option ensures that the drives won't get mounted if you have no network or if you are on the wrong network.



It also makes sure your shares get mounted/unmounted when you switch networks. That's because Debian's if* scripts are triggered when your network configuration changes, and they watch all the filesystems with the _netdev option and do the right thing automagically.



Source



you can check man mount for more information about _netdev



To install the CIFS tools



sudo apt-get install cifs-utils

[#35228] Monday, June 21, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
oneeme

Total Points: 340
Total Questions: 110
Total Answers: 133

Location: Ghana
Member since Fri, Oct 21, 2022
2 Years ago
;