[Samba] Samba 3 dynamically enable or disable share

Dustin C. Hatch admiralnemo at gmail.com
Mon Apr 29 12:45:08 MDT 2013

On 4/29/2013 09:05, Mauricio Alvarez wrote:
> Michael,
>     I really don't want to repartition--again! But yes, your idea is intresting.
You don't need to repartition; you could mount tmpfs on /mnt and use 
something like tmpfiles.d or a custom script to create the mountpoints 
therein at boot. That way you aren't actually wasting disk space for the 
/mnt directory, but you still get the benefit of having it separate from /.

> If there really isn't any other option (really? no-one has ever had this problem in the past?), I was thinking of something like this:
> * Inside each disk, at the root level, create a single directory, call it ROOTDIR01 for DISK1, ROOTDIR02 for disk2 etc.
> * Modify the entries in smb.conf like so:
> path = /mnt/DISK1/ROOTDIR01
> Guest OK = false
> ...
> etc...
> so, if no disk is mounted, we have only /mnt/DISK1 but no ROOTDIR01. If the disk is mounted, the ROOTDIR01 is then visible and gets shared as [STORAGE01]
> Also, the clients see [STORAGE01] as their root dir, ignoring the ROOTDIR01 sub-level
> This is very crude, I wonder if it might work.
>> Wouldn't it be very simple to just create a VERY small partition (e.g. 10MB) on the main drive
>> (the one that your system disk is on), and mount it on e.g. /mnt.
>> Then, even if one of your disks can't mount for some reason, only this very small partition will
>> fill up => no problem for the rest of the system.
>> You would still have to configure your other machines to handle disk full failures and maybe
>> subsequently try another share...
>> Michael
The first thought that came to my mind was usershares. You could write a 
udev rule that mounts a drive when it is connected and then calls `net 
usershare` to share it. It would take a lot of scripting, but it would 
do exactly what you want.


More information about the samba mailing list