Skip to content

Instantly share code, notes, and snippets.

@pocha
Last active December 4, 2025 09:45
Show Gist options
  • Select an option

  • Save pocha/993d18085aeb9b00a75867f684a5a7c5 to your computer and use it in GitHub Desktop.

Select an option

Save pocha/993d18085aeb9b00a75867f684a5a7c5 to your computer and use it in GitHub Desktop.

🛠️ Workarounds to Apply on the macOS Clients (The Macs)

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.

1. Disable Finder Preview and Thumbnails

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:
    1. Open any Finder window connected to the Windows share.
    2. Go to the View menu and select Hide Preview (or press $\text{Shift} \quad + \quad \text{Command} \quad + \quad \text{P}$).
    3. Go to the View menu and select Show View Options (or press $\text{Command} \quad + \quad \text{J}$).
    4. In the View Options window, uncheck the following options:
      • Show icon preview
      • Show preview column (if you are in Column View)
    5. Click the Use as Defaults button at the bottom of the window to apply this to all new Finder windows.

2. Disable .DS_Store File Creation on Network Drives

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).

  1. Open Terminal (Applications > Utilities > Terminal).
  2. Paste and run the following command:
    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
  3. Restart the Finder for the change to take effect:
    killall Finder

3. Change SMB Protocol Settings (Technical/Advanced)

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.

  1. Open Terminal.
  2. Use a text editor (like nano) with sudo to create/edit the file:
    sudo nano /etc/nsmb.conf
  3. 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.
  4. Press $\text{Control} \quad + \quad \text{O}$ to write out (save), $\text{Enter}$, and $\text{Control} \quad + \quad \text{X}$ to exit nano.
  5. Restart the Mac for the SMB settings to take full effect.

🖥️ Workarounds to Check on the Windows Server

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.

1. Disable Windows Indexing on the Shared Drive

The Windows Search Indexing service can sometimes interact poorly with macOS SMB clients, causing file locks.

  1. On the Windows machine, right-click the Shared Drive or Folder and select Properties.
  2. On the General tab, click the Advanced button.
  3. Uncheck the option: Allow files on this drive to have contents indexed in addition to file properties.
  4. Apply the changes to the drive, subfolders, and files.

2. Check for Antivirus or Backup Software

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment