[Samba] Samba 3 dynamically enable or disable share

Mauricio Alvarez maurialvarez303 at rocketmail.com
Mon Apr 29 05:00:38 MDT 2013


Hello,

   I wonder if it is possible to dynamically enable/disable samba 3 shares. 

Here is my problem. 

On a remote server I have 4 removable hard drives, large capacity. I am not using any RAID/JBOD, so each drive is mounted individually (like /mnt/DISK1, /mnt/DISK2 etc) and each drive is individually shared, something like:

[STORAGE01]
path = /mnt/DISK1
Guest OK = false
...

[STORAGE02]
path = /mnt/DISK2
Guest OK = false
... 
etc...

Then I have a bunch of machines that just wait for the share (each machine points to only one share) to be available and then start blindly dumping data into the share (the hosts don't make checks--if the directory structure isn't there, they just re-create it and start dumping data).

Problem is, the samba server is in a remote location and if for any reason one of the drives isn't mounted, samba will share the system drive instead, and this will fill up very fast and lock up my server.

So, I can make a script to mount the external drives, and only if all went well then start samba. But since my system is best-effort, in case say Disk3 fails to mount, I would like to still be able to share /mnt/DISK1, /mnt/DISK2 and /mnt/DISK4 but NOT /mnt/DISK3 (sharename is STORAGE03). 

This would call for either my script to copy to samba.conf one of 2^4 different smb.conf files (covering all possible combinations), then start samba.

This is messy, it would be so much better to be able to selectively enable/disable the shares.


Any other ideas? Thanks in advance!


More information about the samba mailing list