# SMB Client on macOS

### Settings for the macOS smb client

1. Create the file `/etc/nsmb.conf` file with the following content

```toml
[default]
streams=yes
notify_off=yes
soft=yes
port445=no_netbios
protocol_vers_map=6
mc_on=yes
mc_prefer_wired=yes
dir_cache_max_cnt=0
```

2. In a terminal, execute `sudo defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE`. This disables the creation of .DS_Store files on network shares
3. Restart the machine
4. Reconnect all smb shares afterwards.


### Details of the /etc/nsmb.conf settings
| Setting | Value | Description |
|--------|-------|-------------|
| `streams` | `yes` | Enables support for NTFS alternate data streams, allowing macOS to read and write metadata and resource forks on SMB shares that support this feature [^1]. |
| `notify_off` | `yes` | Disables file and directory change notifications from the server, which can reduce network traffic and prevent unnecessary refreshes in Finder [^4]. |
| `soft` | `yes` | Configures soft mounts, meaning that if the server becomes unresponsive, operations will fail quickly instead of hanging indefinitely, improving user experience during network issues [^1]. |
| `port445` | `no_netbios` | Specifies that connections should use direct TCP on port 445 without falling back to NetBIOS over port 139, streamlining the connection process [^2]. |
| `protocol_vers_map` | `6` | Sets the SMB protocol version compatibility bitmap; `6` to force SMB 2 or 3 only [^3]. |
| `mc_on` | `yes` | Enables SMB Multichannel, allowing multiple connections between client and server to increase transfer speeds and provide redundancy [^7]. |
| `mc_prefer_wired` | `yes` | When SMB Multichannel is enabled, this setting prioritizes wired network interfaces over Wi-Fi for better performance and stability [^5]. |
| `dir_cache_max_cnt` | `0` | Disables local caching of directory listings, ensuring that you always see the most current files and folders on an SMB share [^6]. |

After modifying `/etc/nsmb.conf`, disconnect and reconnect any mounted SMB shares for the changes to take effect [^8].

[^1]: [MacOS und SMB nerven | Das deutsche Synology Support Forum](https://www.synology-forum.de/threads/macos-und-smb-nerven.136823/) 

[^2]: [nsmb.conf(5) man page](https://leancrew.com/all-this/man/man5/nsmb.conf.html) 

[^3]: [How to disable SMB 1 or NetBIOS in macOS](https://support.apple.com/en-us/102050) 

[^4]: [DSM 7.2 - Dateien erscheinen nach dem Löschen wieder und lassen...](https://www.synology-forum.de/threads/dateien-erscheinen-nach-dem-loeschen-wieder-und-lassen-sich-dann-nicht-mehr-loeschen.138574/)

[^5]: [Das Verhalten von SMB Multichannel konfigurieren - Apple Support (LI)](https://support.apple.com/de-li/102010) 

[^6]: [Disable local SMB directory enumeration caching](https://support.apple.com/en-mk/101918) 

[^7]: [Configure SMB Multichannel behavior](https://support.apple.com/en-jo/102010) 

[^8]: [Apple macOS smbx and /etc/nsmb.conf information - GitHub](https://github.com/scriptsandthings/macOS_smbx_things)