[Android Stick & Console AMLogic based Computers] redmustangford:
Hello everyone,

For my first thread, I won't ask a question, I will post a solution.

I have recently acquired a second-hand Ugoos X3 device, which is quite a good device.

But I have been really frustrated upon testing it after unboxing it, because despite the fact that this device advertises for the ability of having a Gigabit ethernet port and a builtin samba server, my tests showed a max 11,4 MiB/s instead of rather a 114 MiB/s.

I started to identify the reason, with a vast amount of Googling. After realizing how many people on earth already been through this (mostly unsolved) issue, and after testing the good gigabit-readiness of my Ethernet cable, I dug into the rabbit hole of the system.

I then discovered the root causes, and you won't like it :

- the smbd binary dates from 2005

- the smb.conf is counter-optimized and dates from this 2005 era

See for yourself:

/data/system/samba_________________ug # ./smbd -V
Version 3.0.20a

[global]
interfaces = wlan0 eth0 eth1 eth2
min protocol = SMB2
bind interfaces only = yes
workgroup = WORKGROUP
server string = Samba on Android mediacenter
netbios name = mybox
#remote announce = 255.255.255.255
encrypt passwords = yes
security = SHARE
restrict anonymous = 0
load printers = no
printcap name = /dev/null
disable spoolss = yes
deadtime = 5
delete readonly = yes
nt acl support = no
inherit permissions = yes
socket options = IPTOS_LOWDELAY TCP_NODELAY SO_SNDBUF=64000 SO_RCVBUF=64000 SO_KEEPALIVE
local master = no
unix extensions = yes

[internal storage]
vfs objects = fake_perms
comment = mybox /sdcard
path = /sdcard
force user = root
read only = no
writable = yes
guest ok = yes

A lot of directives in this config file are totally deprecated, and the "socket options" is responsible for capping at 11,4 MiB/s.

So after having spent this vast amount of time finding the issue, I took some to patch.

Here's my solution.

0) Root your device

1) Download the Termux compiled package of your device architecture of the "samba" package : https://grimler.se/termux-packages-24/pool/main/s/samba/

2) On your device, replace the smbd binary with the Termux one, at this location : "/data/system/samba_________________ug"

3) Replace the original "smb.conf" (same directory than previous) configuration with this one (which by way the contains security hardening features and support SMBv2 which allows not installing SMBv1 on Windows...)

[global]
lock dir = /data/local/tmp/lock/
state directory = /data/local/tmp/state/
ncalrpc dir = /data/local/tmp/ncalrpc/

interfaces = wlan0 eth0 eth1 eth2

server min protocol = SMB2
bind interfaces only = yes
workgroup = WORKGROUP
server string = Samba on Android mediacenter
netbios name = mybox
server role = standalone server
security = user
map to guest = Bad Password
usershare allow guests = yes

load printers = no
printcap name = /dev/null
disable spoolss = yes

deadtime = 5
delete readonly = yes
nt acl support = no
inherit permissions = yes
local master = no
disable netbios = yes
smb ports = 445
lm announce = no
multicast dns register = no

[internal storage]
vfs objects = fake_perms
comment = mybox /sdcard
path = /sdcard
force user = root
read only = no
writable = yes
guest ok = yes

4) Edit the "smbd" binary calling line in the "samba-rc" launching script, with this one

$PRE/smbd -D -s /data/system/samba_________________ug/smb.conf

Reboot your device, you now have a best-of-breed samba server and configuration.

A simple but heartful message to Ugoos: update the packages you use in your image ! We need more up-to-date binaries and configuration from your products ! Provide firmwares that does not require to make people do insecure stuff such as installing SMBv1 client on their client !

I am really grateful to these resources which helped a lot:

- https://lafibre.info/nas/perfs-moisies-avec-samba/ (sorry, in french, use google translate)

- https://serverfault.com/questions/470650/samba-configuration-for-public-shares/700449#700449

- https://blog.hiebl.cc/posts/why-your-samba-config-does-not-work/