The /mnt directory is empty, neither directory exists. I can delete them any time I want from Network Shares - Shared Directories, and that works until the next reboot when both return.
My mounted filesystems and mount points look like this:
I can add additional Samba shares and those work fine, but I'd like to remove these two that show up on my network, but can't be accessed. I suspect the problem is in /etc/init.d/samba and that the shares are being recreated when that script runs at boot, but I can't work out how.
The SAMBA configuration file (/etc/samba/smb.conf) is created (each time SAMBA is started) from /etc/samba/smb.conf.template and /etc/config/samba. Have a look to both files and look for your shares there.
That's what I thought initially too. However, if I comment out the lines in samba.conf and smb.conf having to do with the shares I don't want -- they come back on the next reboot.
Here's the contents of /etc/samba/samba.conf.template:
[global]
netbios name = |NAME|
display charset = |CHARSET|
interfaces = |INTERFACES|
server string = |DESCRIPTION|
unix charset = |CHARSET|
workgroup = |WORKGROUP|
local master = no
browseable = yes
deadtime = 30
domain master = yes
encrypt passwords = yes
enable core files = no
guest ok = yes
invalid users = root
load printers = no
map to guest = Bad User
max protocol = SMB2
min receivefile size = 16384
null passwords = yes
passdb backend = smbpasswd
preferred master = yes
security = user
smb passwd file = /etc/samba/smbpasswd
syslog = 2
use sendfile = yes
writeable = yes
bind interfaces only = yes
And, finally /var/etc/smb.conf which is linked to /etc/samba/smb.conf
[global]
netbios name = ROOter
display charset = UTF-8
interfaces = 127.0.0.1/8 lo 192.168.2.1/24 fd63:7226:edba::1/60 br-lan
server string = ROOter
unix charset = UTF-8
workgroup = WORKGROUP
local master = no
browseable = yes
deadtime = 30
domain master = yes
encrypt passwords = yes
enable core files = no
guest ok = yes
invalid users = root
load printers = no
map to guest = Bad User
max protocol = SMB2
min receivefile size = 16384
null passwords = yes
passdb backend = smbpasswd
preferred master = yes
security = user
smb passwd file = /etc/samba/smbpasswd
syslog = 2
use sendfile = yes
writeable = yes
bind interfaces only = yes
[homes]
comment = Home Directories
browsable = no
read only = no
create mode = 0750
[mmcblk0p1]
path = /mnt/mmcblk0p1
read only = no
guest ok = yes
[mmcblk0p2]
path = /mnt/mmcblk0p2
read only = no
guest ok = yes
No amount of commenting out the samba shares I don't want in either of the two files that contain references to them will survive a reboot. The comment "#" marks just disappear and the file is right back the way it was. Samba shares mmcblk0p1 and mmcblk0p2 are being really stubborn!
Here's my /etc/init.d/samba script:
#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2012 OpenWrt.org
START=60
USE_PROCD=1
smb_header() {
config_get samba_iface $1 interface "loopback lan"
# resolve interfaces
local interfaces=$(
. /lib/functions/network.sh
local net
for net in $samba_iface; do
local device
network_is_up $net || continue
network_get_device device "$net" && {
local subnet
network_get_subnet subnet "$net" && echo -n "$subnet "
network_get_subnet6 subnet "$net" && echo -n "$subnet "
}
echo -n "${device:-$net} "
done
)
local name workgroup description charset
local hostname="$(uci_get system.@system[0].hostname)"
config_get name $1 name "${hostname:-Lede}"
config_get workgroup $1 workgroup "${hostname:-Lede}"
config_get description $1 description "Samba on ${hostname:-Lede}"
config_get charset $1 charset "UTF-8"
mkdir -p /var/etc
sed -e "s#|NAME|#$name#g" \
-e "s#|WORKGROUP|#$workgroup#g" \
-e "s#|DESCRIPTION|#$description#g" \
-e "s#|INTERFACES|#$interfaces#g" \
-e "s#|CHARSET|#$charset#g" \
/etc/samba/smb.conf.template > /var/etc/smb.conf
local homes
config_get_bool homes $1 homes 0
[ $homes -gt 0 ] && {
cat <<EOT >> /var/etc/smb.conf
[homes]
comment = Home Directories
browsable = no
read only = no
create mode = 0750
EOT
}
[ -L /etc/samba/smb.conf ] || ln -nsf /var/etc/smb.conf /etc/samba/smb.conf
}
smb_add_share() {
local name
local path
local users
local read_only
local guest_ok
local create_mask
local dir_mask
local browseable
config_get name $1 name
config_get path $1 path
config_get users $1 users
config_get read_only $1 read_only
config_get guest_ok $1 guest_ok
config_get create_mask $1 create_mask
config_get dir_mask $1 dir_mask
config_get browseable $1 browseable
[ -z "$name" -o -z "$path" ] && return
echo -e "\n[$name]\n\tpath = $path" >> /var/etc/smb.conf
[ -n "$users" ] && echo -e "\tvalid users = $users" >> /var/etc/smb.conf
[ -n "$read_only" ] && echo -e "\tread only = $read_only" >> /var/etc/smb.conf
[ -n "$guest_ok" ] && echo -e "\tguest ok = $guest_ok" >> /var/etc/smb.conf
[ -n "$create_mask" ] && echo -e "\tcreate mask = $create_mask" >> /var/etc/smb.conf
[ -n "$dir_mask" ] && echo -e "\tdirectory mask = $dir_mask" >> /var/etc/smb.conf
[ -n "$browseable" ] && echo -e "\tbrowseable = $browseable" >> /var/etc/smb.conf
}
init_config() {
config_load samba
config_foreach smb_header samba
config_foreach smb_add_share sambashare
}
service_triggers() {
procd_add_reload_trigger samba
local i
for i in $samba_iface; do
procd_add_reload_interface_trigger $i
done
}
start_service() {
init_config
procd_open_instance
procd_set_param command /usr/sbin/smbd -F
procd_set_param respawn
procd_set_param file /var/etc/smb.conf
procd_close_instance
procd_open_instance
procd_set_param command /usr/sbin/nmbd -F
procd_set_param respawn
procd_set_param file /var/etc/smb.conf
procd_close_instance
}
I'm just not seeing where the re-birth of these shares every reboot is coming from!
The SAMBA configuration file (/etc/samba/smb.conf) is created (each time SAMBA is started) from /etc/samba/smb.conf.template and /etc/config/samba. There is no point in editing /etc/samba/smb.conf, it will be overwritten; you must look for your shares on /etc/samba/smb.conf.template and /etc/config/samba.
Thanks for the feedback -- and I wish it was that simple! However, deleting the shares from /etc/config/samba.conf (which is also what happens when you remove the shares from the GUI), works only temporarily. On the next reboot, the shares return.
This same behavior is happening on my x86 VirtualBox installation too. Could this be something unique to the way that ext4 builds are setup? The shares are being re-added to samba.conf during the boot sequence, any idea how?
As far as I can tell, those partitions aren't being mounted. If you look at my first post in this thread you'll see my mounted file systems and mount points. Two devices are listed under mount points at those locations, but as you can see, they're not enabled. Further, the UUID of the first doesn't even appear valid. The /mnt directory is empty when looked at using WinSCP.
Here's a snippet from my log that may be relevant:
Tue Sep 19 16:12:17 2017 daemon.err block: /dev/mmcblk0p1 is already mounted on /boot
Tue Sep 19 16:12:17 2017 user.notice 30-mount: /mnt/mmcblk0p1 shared as mmcblk0p1
Tue Sep 19 16:12:18 2017 daemon.err block: /dev/mmcblk0p2 is already mounted on /
Tue Sep 19 16:12:18 2017 user.notice 30-mount: /mnt/mmcblk0p2 shared as mmcblk0p2
The goal here is to get rid of the unwanted SAMBA shares, but perhaps there's a larger issue with the file system setup on these ext4 builds. Any thoughts?
ROOter is just a build of LEDE that focuses on being ready-to-deploy (useful packages pre-installed) with an emphasis on USB cellular modems. I use that forum too, if I have issues related to their build, but I don't think that's the case here. How file systems are setup is not a ROOter feature, so I'm fairly sure this problem is being carried forward from the Raspberry Pi and x86 versions of LEDE.
I think this is not related to file system, but to samba setup.
I don't recall samba being a standard feature of LEDE (I might be wrong in the case of RPi), hence guessing those samba shares have been added by the rooter creators.
So, for anyone interested in the resolution of this issue, it's being caused by a script /etc/hotplug.d/block/30-mount which is intended to automatically mount new devices as SAMBA shares on boot-up. Handy for USB drive devices I imagine. The script is meant to contain exclusions for the primary file systems, but does not for the Raspberry Pi or x86 distros. You can, of course, still mount individual directories from the primary file system as SAMBA shares.
The relevant section of code from 30-mount is here:
if [ `basename $blkdev` != "block" ]; then
device=`basename $DEVPATH`
if echo $device | grep -q "mtdblock"; then
exit 0
fi
But needs to look like this if you want to exclude mounting of primary file systems for the RPi and x86 builds:
if [ `basename $blkdev` != "block" ]; then
device=`basename $DEVPATH`
if echo $device | grep -q "mtdblock"; then
exit 0
fi
if echo $device | grep -q "mmcblk"; then
exit 0
fi
if echo $device | grep -q "sda1"; then
exit 0
fi
if echo $device | grep -q "sda2"; then
exit 0
fi
The idea is for the script to exit and move on to the next device if a name match is found to one of the specified devices. Here's the entire script:
#!/bin/sh /etc/rc.common
. /lib/functions.sh
# Copyright (C) 2011 OpenWrt.org
log() {
logger -t "30-mount" "$@"
}
sanitize() {
sed -e 's/[[:space:]]\+$//; s/[[:space:]]\+/_/g' "$@"
}
if [ ! -f /tmp/bootend.file ]; then
sleep 10
while [ ! -f /tmp/bootend.file ]; do
sleep 1
done
log "Delay Block Mount for boot up"
fi
blkdev=`dirname $DEVPATH`
if [ `basename $blkdev` != "block" ]; then
device=`basename $DEVPATH`
if echo $device | grep -q "mtdblock"; then
exit 0
fi
if echo $device | grep -q "mmcblk"; then
exit 0
fi
if echo $device | grep -q "sda1"; then
exit 0
fi
if echo $device | grep -q "sda2"; then
exit 0
fi
case "$ACTION" in
add)
DEVN=${DEVNAME:0:3}
MODEL=$(sanitize "/sys/block/$DEVN/device/model")
if [ -d /etc/samba ]; then
uci delete samba.$device
uci set samba.$device=sambashare
uci set samba.$device.name=$MODEL$DEVNAME
uci set samba.$device.path=/mnt/$device
uci set samba.$device.read_only=no
uci set samba.$device.guest_ok=yes
uci commit samba
/etc/init.d/samba restart
log "/mnt/$device shared as $MODEL$DEVNAME"
fi
;;
remove)
log "remove /mnt/$device"
if [ -d /etc/samba ]; then
uci delete samba.$device
uci commit samba
fi
;;
esac
fi
Hopefully, this will save someone some time in the future chasing down unwanted re-appearing shares!
I figured it out myself -- but your comment about SAMBA not being a stock part of LEDE got me thinking that I should look through the ROOter build script to see what additional packages and/or scripts separate stock LEDE from the ROOter build. I also built a LEDE x86 VirtualBox machine to confirm what you said.
Looking at the build download from ROOter, the 30-mount script was the only thing under ext-samba besides the Makefile. After that, it was fairly obvious what the script was trying to do, and why the SAMBA shares kept being re-created.