These settings help prevent macOS services from trying to preview or index files on the network share, which is often the cause of the unnecessary locks.
The Finder's built-in Quick Look and icon preview features are major culprits, as they open the file to generate a preview, which triggers a read lock.
-
For Every User on Every Mac:
- Open any Finder window connected to the Windows share.
- Go to the View menu and select Hide Preview (or press
$\text{Shift} \quad + \quad \text{Command} \quad + \quad \text{P}$ ). - Go to the View menu and select Show View Options (or press
$\text{Command} \quad + \quad \text{J}$ ). - In the View Options window, uncheck the following options:
- Show icon preview
- Show preview column (if you are in Column View)
- Click the Use as Defaults button at the bottom of the window to apply this to all new Finder windows.
Finder creates hidden .DS_Store files in every folder to save view preferences. This constant writing can interfere with file operations and locking. You can prevent this via the Terminal (this is a per-user setting).
- Open Terminal (Applications > Utilities > Terminal).
- Paste and run the following command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
- Restart the Finder for the change to take effect:
killall Finder
You can configure the SMB client on the Mac to disable features known to cause locking issues. This involves editing or creating the nsmb.conf file in the /etc/ directory.
Note: This is an advanced system setting. Back up the file if it exists, and be careful with your edits.
- Open Terminal.
- Use a text editor (like
nano) withsudoto create/edit the file:sudo nano /etc/nsmb.conf
- Add the following lines to the file:
[default] file_ids_off=yes streams=yes notify_off=yes-
file_ids_off=yes: This disables File ID caching, which can often be the source of persistent locks. -
notify_off=yes: This disables change notifications, which can sometimes also lead to locking issues.
-
- Press
$\text{Control} \quad + \quad \text{O}$ to write out (save),$\text{Enter}$ , and$\text{Control} \quad + \quad \text{X}$ to exitnano. - Restart the Mac for the SMB settings to take full effect.
If the above Mac-side changes don't fully resolve the issue, you should investigate settings on the Windows server side, particularly those related to indexing and file leases.
The Windows Search Indexing service can sometimes interact poorly with macOS SMB clients, causing file locks.
- On the Windows machine, right-click the Shared Drive or Folder and select Properties.
- On the General tab, click the Advanced button.
- Uncheck the option: Allow files on this drive to have contents indexed in addition to file properties.
- Apply the changes to the drive, subfolders, and files.
Some security or backup applications running on the Windows server can be overly aggressive in scanning files immediately after a Mac client accesses them, which can temporarily re-establish a lock. Try temporarily disabling such services (if safe to do so) to see if the issue goes away.
I recommend starting with disabling Finder Preview and Thumbnails (Step 1) and disabling .DS_Store creation (Step 2) on one or two Mac test machines, as these are the least disruptive and most commonly successful fixes.
Do you have access to the Windows machine's settings, or would you prefer to focus only on solutions for the Mac clients?