Samba: Windows shares SliTaz 5.1

Windows machines and most NAS boxes share files with the SMB protocol, also called CIFS. SliTaz can use their shares, and share its own folders with them.

Three packages do the job:

smbclient and samba are version 3.6, from 2012. They speak the old SMB1 protocol by default, which Windows 10 and 11 have turned off.

There is no graphical way: the file manager does not open smb:// addresses. Mount the share, then open its folder in the file manager.

Mount a share

As root, install the package and make a folder to mount the share on:

# spk-add cifs-utils
# mkdir -p /mnt/nas

Then mount the share share of the machine nas:

# mount.cifs //nas/share /mnt/nas -o username=me,uid=1000,gid=100
Password for me@//nas/share:

If the name nas is not found, use its IP address, or add it to /etc/hosts. To unmount:

# umount /mnt/nas

Without typing the password

Put the user name and the password in a file readable by root only:

# cat > /root/.smbcred << EOT
username=me
password=the password
EOT
# chmod 600 /root/.smbcred
# mount.cifs //nas/share /mnt/nas -o credentials=/root/.smbcred,uid=1000,gid=100

At boot

SliTaz brings the network up in the background, so a mount made too early at boot fails. This waits up to 30 seconds for the server, at the end of /etc/init.d/local.sh:

( for i in $(seq 30); do
	ping -c 1 -W 1 nas > /dev/null 2>&1 && break
	sleep 1
  done
  mount.cifs //nas/share /mnt/nas -o credentials=/root/.smbcred,uid=1000,gid=100 ) &

List and copy with smbclient

# spk-add smbclient
$ smbclient -L nas -U me

lists the shares of nas. To open one:

$ smbclient //nas/share -U me
smb: \> help

At the smb: \> prompt, ls, cd, get file, put file and quit work as in an FTP client.

smbclient 3.6 uses SMB1 by default: a recent Windows or NAS refuses it. Try -m SMB2, or mount the share with mount.cifs, which does not have this problem.

Share folders with Windows

Samba 3.6 is old and no longer gets security fixes. Run it only on a local network you trust, never facing the Internet.

# spk-add samba

Samba has its own passwords. Each user who opens the share needs a Linux account and a Samba password; using the same name and password as on the Windows machine saves a prompt:

# adduser smbuser
# smbpasswd -a smbuser

The configuration is /etc/samba/smb.conf. A shared folder, readable and writable by smbuser:

[global]
	workgroup = WORKGROUP
	security = user
	max protocol = SMB2

[share]
	path = /home/share
	read only = no
	valid users = smbuser

max protocol = SMB2 lets Windows 10 and 11 connect without SMB1. The folder must exist and belong to the user:

# mkdir -p /home/share
# chown smbuser /home/share

Check the file, then start the server and add it to the services started at boot:

# testparm
# /etc/init.d/samba start
# trame service enable samba

From Windows, open \\192.168.0.6\share (the address of the SliTaz machine) in the file explorer. The firewall of SliTaz lets the local network in by default; if you changed its rules, open TCP ports 139 and

Troubleshooting

"mount error(13): Permission denied": wrong user name or password. Check them from another machine first.

"mount error(95): Operation not supported": the server and the client found no protocol version in common. An old NAS may only speak SMB1: add vers=1.0 to the options.

Windows does not see the SliTaz share: try the address (\\192.168.0.6\share) rather than the name, and check that max protocol = SMB2 is in the [global] part of smb.conf.