Avoid samba shares external units


#1

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


#2

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


#3

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…


#4

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.