Tested on macOS Monterey (12), should work on newer versions. For Apple Silicon, adjust Homebrew paths from /usr/local to /opt/homebrew.
brew install cmake gnutls jansson libarchive openssl pkg-config python@3.11
brew install readline && brew link --force readline
brew install bison icu4c libxcrypt
cpan install Parse::Yapp::Driver
cpan install JSONUnlink older ICU versions if present:
brew unlink icu4c@74 2>/dev/null
brew unlink icu4c@76 2>/dev/null
brew link icu4c --force 2>/dev/null || trueSet paths (add to ~/.zshrc for persistence):
export PATH="/usr/local/opt/bison/bin:$PATH"
export PKG_CONFIG_PATH="/usr/local/opt/libarchive/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libxcrypt/lib/pkgconfig"
export CPPFLAGS="-I/usr/local/opt/libarchive/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@3/include -I/usr/local/opt/icu4c/include -I/usr/local/opt/libxcrypt/include"
export LDFLAGS="-L/usr/local/opt/libarchive/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl@3/lib -L/usr/local/opt/icu4c/lib -L/usr/local/opt/libxcrypt/lib"git clone https://git.samba.org/samba.git
cd samba
git checkout samba-4.23.5Minimal build for file server:
./configure --prefix=/opt/samba \
--without-ad-dc \
--without-acl-support \
--without-gettext \
--without-pam \
--without-ldap \
--without-ads \
--without-winbind \
--without-json \
--without-gpgme \
--without-quotas \
--without-utmp \
--without-syslog \
--without-automount \
--without-dmapi \
--without-fam \
--without-profiling-data \
--without-libunwind \
--without-systemd \
--without-lttng \
--without-regedit \
--without-winexe \
--without-cluster-support \
--without-prometheus-exporter \
--disable-spotlight \
--disable-cups \
--disable-iprint \
--disable-python \
--disable-glusterfs \
--disable-cephfs
make -j$(sysctl -n hw.ncpu)
sudo make install/opt/samba/sbin/smbd --version
otool -L /opt/samba/sbin/smbd | head -5 # Should show /opt/samba/lib pathsCreate log directory:
sudo mkdir -p /var/log/sambaCreate /opt/samba/etc/smb.conf:
[global]
workgroup = WORKGROUP
netbios name = server
load printers = no
printing = bsd
printcap name = /dev/null
log file = /var/log/samba/samba.log
log level = 1
max log size = 10000
passdb backend = tdbsam:/etc/passdb.tdb
# SMB protocol settings
server min protocol = SMB2
server max protocol = SMB3
[MyShare]
path = /Volumes/MyDrive/
browsable = yes
writable = yes
guest ok = no
force user = yourusername
force group = staff
vfs mkdir use tmp name = no
veto files = /Thumbs.db/.DS_Store/._*/.Spotlight-V100/.Trashes/
delete veto files = yesImportant for APFS volumes: The vfs mkdir use tmp name = no setting is required. Without it, directory creation fails with NT_STATUS_ACCESS_DENIED due to how APFS handles renameat() with special characters in temp filenames.
sudo /opt/samba/bin/smbpasswd -a yourusernameCreate three plist files for automatic startup:
1. /Library/LaunchDaemons/com.samba.smbd.plist — File server:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.samba.smbd</string>
<key>ProgramArguments</key>
<array>
<string>/opt/samba/sbin/smbd</string>
<string>--foreground</string>
<string>--no-process-group</string>
<string>-s</string>
<string>/opt/samba/etc/smb.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
<key>Crashed</key>
<true/>
</dict>
</dict>
</plist>2. /Library/LaunchDaemons/com.samba.nmbd.plist — Windows/NetBIOS discovery:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.samba.nmbd</string>
<key>ProgramArguments</key>
<array>
<string>/opt/samba/sbin/nmbd</string>
<string>--foreground</string>
<string>--no-process-group</string>
<string>-s</string>
<string>/opt/samba/etc/smb.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>3. /Library/LaunchDaemons/com.samba.bonjour.plist — Mac/Bonjour discovery:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.samba.bonjour</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/dns-sd</string>
<string>-R</string>
<string>server</string>
<string>_smb._tcp</string>
<string>local</string>
<string>445</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>Load all services:
sudo launchctl load /Library/LaunchDaemons/com.samba.smbd.plist
sudo launchctl load /Library/LaunchDaemons/com.samba.nmbd.plist
sudo launchctl load /Library/LaunchDaemons/com.samba.bonjour.plistStop services:
sudo launchctl unload /Library/LaunchDaemons/com.samba.smbd.plist
sudo launchctl unload /Library/LaunchDaemons/com.samba.nmbd.plist
sudo launchctl unload /Library/LaunchDaemons/com.samba.bonjour.plistReload config without restart:
sudo /opt/samba/bin/smbcontrol all reload-config- nmbd — NetBIOS discovery for Windows clients (UDP ports 137-138)
- dns-sd — Bonjour/mDNS discovery for Mac clients (uses macOS built-in mDNSResponder)
Avahi is not used on macOS because it conflicts with the built-in mDNSResponder on port 5353.
If Windows doesn't see the server in Network:
- Set network to Private (not Public)
- Enable "SMB 1.0/CIFS Client" in Windows Features (for NetBIOS discovery)
- Or connect directly:
\\server\ShareNameor\\192.168.x.x\ShareName
Disable Thumbs.db creation on Windows (recommended):
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v DisableThumbnailCache /t REG_DWORD /d 1 /fCheck services are running:
ps aux | grep -E "smbd|nmbd|dns-sd"Test from Mac terminal:
smbutil view //username@serverTest from Windows:
net view \\serverView logs:
tail -f /var/log/samba/samba.log- https://wiki.samba.org/index.php/Build_Samba_from_Source
- https://bugzilla.samba.org/show_bug.cgi?id=15864 (vfs mkdir tmp name issue)