Hello SONOS-USERS,
I tried a few things today to get Sonos to accept the music library from my Samba share without aborting after a short time with an error stating that the share is no longer available. Most of the information I found used outdated configuration settings or was incorrect. Here is the complete Samba Sample-Configuration:
/etc/samba/smb.conf
# Sample-Config for Sonos and Samba
[global]
bind interfaces only = yes
interfaces = YOUR.RASPI-IP-Adress eth0
# Logging
log file = /var/log/samba/log.%m
logging = file
# Auth / Compatibility
ntlm auth = ntlmv1-permitted
server min protocol = SMB2
server max protocol = SMB3
# ID Mapping
idmap config * : backend = tdb
#======================= Share Definitions =======================
[MP3-Musik]
comment = MP3-Musik
path = /media/musik
valid users = Your-MP3-Music-USERNAME
create mask = 0444
directory mask = 0555
Next, the user must be created correctly:
sudo useradd -M -s /usr/sbin/nologin YOUR-MP3-Music-USERNAME
sudo smbpasswd -a Your-MP3-Music-USERNAME
sudo smbpasswd -e Your-MP3-Music-USERNAME
It is important that the files and folders in /media/musik are owned by the user Your-MP3-Music-USERNAME and are at least readable by everyone.
sudo chown -R Your-MP3-Music-USERNAME:Your-MP3-Music-USERNAME /media/musik
and then set everything to read-only:
sudo chmod 444 /media/musik/*
Finally, check if the Samba user exists:
sudo pdbedit -L
It should display:
Your-MP3-Music-USERNAME:1001:
Also, check the Samba user details. Important points:
Account Flags: [U] → User active
Account Flags: [D] → User disabled
Password last set → Password exists
Check if the user exists as a Linux user:
getent passwd Your-MP3-Music-USERNAME
Sonos loses the connection if the share is unreadable.
Sonos loses the connection if the path is too long.
Sonos has a hard limit: max. 256 characters per path and max. 65,000 files per library
Sonos loses the connection if the path does not exactly match the share name.
Specifying the shared folder in the Sonos app is crucial. You must enter the correct path obtained from `sudo pdbedit -Lv MP3-Musik` here; for example, the output looks like this:
...
Home Directory: \\RASPBERRYPI4\mp3-musik
...
In this case, `\\RASPBERRYPI4\MP3-Musik` must be used as the shared folder, and you must ensure that the username and password and Share MP3-Musik are entered with the correct capitalization (case-sensitive) without the []-Brackets from the smb.conf.
Now: Enjoy your Music.
This is just a brief guide, as I couldn't find the necessary information elsewhere. It could certainly be improved, but it is sufficient for the purpose of local music playback via Samba.
I hope you have fun and success with Sonos.
