Avoid samba shares external units

By default samba shares osmc folder and external units mount under /media/ path. How to avoid samba mounts media units?.
I have osmc and retropie system in the same SD card, and retropie system folders are mounted under media when I boot on osmc (I want to avoid share these foldres).

Thank in advances

If you connect via SSH and type

sudo nano /etc/samba/smb.conf

and delete:

[osmc]
browsable = yes
read only = no
valid users = osmc
path = /home/osmc
comment = OSMC Home Directory

[automount template]
browseable = yes
-valid = no
valid users = osmc
path = %P
hide files = /$RECYCLE.BIN/System Volume Information/desktop.ini/thumbs.db/

then press CTRL+X, press Y, then type reboot then you shouldn’t see those shares anymore

EDIT:
Just read original post. If you want to retain the OSMC home folder only removing the automount shares then don’t delete:

[osmc]
browsable = yes
read only = no
valid users = osmc
path = /home/osmc
comment = OSMC Home Directory

1 Like

I have removed:

[automount template]
browseable = yes
-valid = no
valid users = osmc
path = %P
hide files = /$RECYCLE.BIN/System Volume Information/desktop.ini/thumbs.db/

But the automount shares under media folder still show in samba clients…

I’ve just noticed that smb.conf automatically gets overwritten and changes destroyed on updates anyway possibly on reboot though I’m not 100% sure.

Try this instead:

Create a new file called smb-local.conf in the same directory as smb.conf (/etc/samba/) and insert the following lines:

[global]

   #If you only need to add some additional shares see smb-shares.conf below for a simpler way to do this.

    workgroup = WORKGROUP
    security=user
    follow symlinks = yes
    wide links = no
    unix extensions = no
    lock directory = /var/cache/samba
    load printers = no
    printing = bsd
    printcap name = /dev/null
    disable spoolss = yes
    log level = 1
    map to guest = bad user
#   usershare template share = automount template

# Automount template disabled to work around a samba bug causing crashes accessing external drives.

    read raw = Yes
    write raw = Yes
    strict locking = no
    min receivefile size = 16384
    use sendfile = true
    aio read size = 2048
    aio write size = 2048
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072

[osmc]
    browsable = yes
    read only = no
    valid users = osmc
    path = /home/osmc
    comment = OSMC Home Directory

#[automount template]
#    browseable = yes
#    -valid = no
#    valid users = osmc
#    path = %P
#    hide files = /$RECYCLE.BIN/System Volume Information/desktop.ini/thumbs.db/

# Add custom shares in smb-shares.conf instead of editing smb.conf so they will not be
# overwritten by samba updates. You can only add new shares to smb-shares.conf, not change
# the default shares or global options. If you need full control see smb-local.conf above.

include = /etc/samba/smb-shares.conf

Let me know if it works? If it doesn’t I could be due to udisk-glue automatically still automatically generating the shares in which case to prevent updating that file you could try changing smb-local.conf to:

[global]

   #If you only need to add some additional shares see smb-shares.conf below for a simpler way to do this.

    workgroup = WORKGROUP
    security=user
    follow symlinks = yes
    wide links = no
    unix extensions = no
    lock directory = /var/cache/samba
    load printers = no
    printing = bsd
    printcap name = /dev/null
    disable spoolss = yes
    log level = 1
    map to guest = bad user
   usershare template share = automount template


    read raw = Yes
    write raw = Yes
    strict locking = no
    min receivefile size = 16384
    use sendfile = true
    aio read size = 2048
    aio write size = 2048
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072

[osmc]
    browsable = yes
    read only = no
    valid users = osmc
    path = /home/osmc
    comment = OSMC Home Directory

[automount template]
    browseable = no
    -valid = no
    valid users = osmc
    path = %P
    hide files = /$RECYCLE.BIN/System Volume Information/desktop.ini/thumbs.db/

# Add custom shares in smb-shares.conf instead of editing smb.conf so they will not be
# overwritten by samba updates. You can only add new shares to smb-shares.conf, not change
# the default shares or global options. If you need full control see smb-local.conf above.

include = /etc/samba/smb-shares.conf

That last fix is more of a workaround and only should be used if the first fix doesn’t work as it still leaves the shares open just invisible.

I have already tried smb-local.conf and it didn’t work

Unfortunately I’m not quite sure how to proceed then if I’m honest. I would have thought that editing those files would have worked though if not then Samba must be configured elsewhere. Maybe one of the devs can best answer this? @sam_nazarko ? @DBMandrake ?

Did you rebooted afterwards?
I suggest you remove the lines again, reboot and upload full logs afterwards so that we can help

1 Like