Skip to content

Instantly share code, notes, and snippets.

@fschiettecatte
Last active November 17, 2025 14:16
Show Gist options
  • Select an option

  • Save fschiettecatte/02d61e3d36c5f8d36bd45586fc5d0dc7 to your computer and use it in GitHub Desktop.

Select an option

Save fschiettecatte/02d61e3d36c5f8d36bd45586fc5d0dc7 to your computer and use it in GitHub Desktop.
Setting up SAMBA for Linux / MacOS

Setting up Samba for Linux / MacOS

I recently (re)switched from using Netatalk to Samba for file access from macOS (15.x) to linux (AlmaLinux 9.x).

Obviously the Samba is a great resource, on the Samba Wiki the Configure Samba to Work Better with Mac OS X was invaluable for setting up the /etc/samba/smb.conf file, and the vfs fruit man page contains documentation for all the options.

Here is the /etc/samba/smb.conf file I use:

[global]

    workgroup = LINUX
    server string = linux.internal (Samba)
    security = user

    # Network interface
    bind interfaces only = yes
    interfaces = 10.0.1.150/24

    # Password backend
    passdb backend = tdbsam

    # Always sync to disk (optional)
#    sync always = yes

    # Use extended POSIX ACLs
    inherit acls = yes

    # Set default file & directory permissions
    create mask = 0664
    directory mask = 0775

    # Linux supports kernel oplocks
    # Apple changed something with their SMB client in macOS 13 (Ventura) causing
    # it to place opportunitics locks on files being edited resulting in a
    # 'text file busy' error on the Linux side when attempting to execute the script.
    # Setting 'kernel oplocks = yes' works around this issue.
    # Present in macOS 14 (Sonoma) (Accessing Linux Samba 4.20.x)
    # Present in macOS 15 (Sequoia) (Accessing Linux Samba 4.21.x)
#    kernel oplocks = yes

    # Added for Mac Client support
    # https://wiki.samba.org/index.php/Configure_Samba_to_Work_Better_with_Mac_OS_X
    # https://www.samba.org/samba/docs/current/man-html/vfs_fruit.8.html
    min protocol = SMB3
    ea support = yes
    vfs objects = fruit streams_xattr
    fruit:metadata = stream
    fruit:model = MacSamba
    fruit:veto_appledouble = no
    fruit:nfs_aces = no
    fruit:wipe_intentionally_left_blank_rfork = yes
    fruit:delete_empty_adfiles = yes
    fruit:posix_rename = yes
    fruit:zero_file_id = yes

#    printing = cups
#    printcap name = cups
#    load printers = yes
#    cups options = raw

[homes]
    comment = Home Directories
    valid users = %S, %D%w%S
    browseable = no
    writeable = yes

There is an option worth noting, Apple changed something with their SMB client in Ventura and I needed to add the 'kernel oplocks = yes' options because MacOS would place opportunitics locks on the files I was editing and I would get a 'text file busy' error on the linux side when I tried to run scripts. Setting 'kernel oplocks = yes' helped to work around this. Setting this option is only useful if you edit code on a Mac and execute this code on the Linux machine.

I also made some changes to '/etc/nsmb.conf' on the Mac, here is the version I use:

[default]

# Require SMB3
# 7 == 0111  SMB 1/2/3 should be enabled
# 6 == 0110  SMB 2/3 should be enabled
# 4 == 0100  SMB 3 should be enabled
protocol_vers_map=4

# SMB TCP/UDP ports:
# both: Attempt to connect via port 445. If that is unsuccessful, try to connect via NetBIOS.
# netbios_only: Do not attempt to connect via port 445.
# no_netbios: Attempt to connect via port 445. If that is unsuccessful, do not try NetBIOS.
port445=no_netbios

# Set hard or soft mount of shares
# Hard mount: a request is issued repeatedly until the request is satisfied.
# Soft mount: tried until completed, the retry limit is met or the timeout limit is met.
#soft=yes

# Disable multichannel support if you have both Wi-Fi and wired networks
mc_on=no

# Some Wi-Fi networks advertise faster speeds than the connected wired network
mc_prefer_wired=yes


# Apple SMB extensions:

# ReadDirAttr: This feature changes how macOS handles reads of file metadata stored in
# alternate data stream when listing the contents of large directories. Finder info,
# access rights, and resource fork size are returned more efficiently for the files
# in the directory.
# ???

# OsxCopyFile: With the SMB2 protocol, Microsoft implemented server-side optimizations
# when copying files between directories on the file share. The extension introduced by
# Apple ensures that all Apple-specific file metadata is properly copied along with the file
# itself. The copy process is also simplified as it is executed in just one request as
# opposed to splitting the requests into logical chunks which was the case in
# the original feature.
#aapl_off=false

# File IDs are legacy compatibility elements for AFP and are not supported by SMB.
#file_ids_off=yes

# Disable Directory caching. macOS will re-download the full contents of the
# folder(s) and metadata every time you browse an SMB share.
#dir_cache_off=yes
@fschiettecatte
Copy link
Author

I think there are multiple things going on there.

First you don't need to set DSDontWriteNetworkStores to False, it's the default, so setting it does nothing,

Second let the Finder manage the .DS_STORE files for your, they store information on how the folder is displayed on the Mac, for example sort order, sizes, etc... Basically the "View Options".

Third, color tags are stored in Extended Attributes which are stored separately from .DS_STORE, if you want to preserve those then you will need to use the Finder to copy those files.

@hackaro
Copy link

hackaro commented Nov 8, 2025

I think there are multiple things going on there.

Surely! :-D Thanks for the reply! :-)

First you don't need to set DSDontWriteNetworkStores to False, it's the default, so setting it does nothing,
ok, I didn't know about that.

Second let the Finder manage the .DS_STORE files for you, they store information on how the folder is displayed on the Mac, for example sort order, sizes, etc... Basically the "View Options".

ok, interesting! How can I get this?

Third, color tags are stored in Extended Attributes which are stored separately from .DS_STORE, if you want to preserve those then >you will need to use the Finder to copy those files.

ok, I will. I've only dealt with Macs in my office.

@fschiettecatte
Copy link
Author

"View Options" are accessed by right-clicking on a Finder window, or you can access some of them directly by clicking on the icons at the top of a Finder window.

@hackaro
Copy link

hackaro commented Nov 8, 2025

"View Options" are accessed by right-clicking on a Finder window, or you can access some of them directly by clicking on the icons at the top of a Finder window.

ok, therefore there is nothing to to have correctly setup the .DS_STORE file in the network share?

@fschiettecatte
Copy link
Author

Indeed, I checked my set up and the 'DSDontWriteNetworkStores' is not even present, so Finder is automatically managing the .DS_Store files for me.

@hackaro
Copy link

hackaro commented Nov 9, 2025

Thanks 🙏

@hackaro
Copy link

hackaro commented Nov 15, 2025

Another couple of questions:

  1. is there a way to a recycle bin working on SMB shares too?
  2. How to get the network shares properly indexed by Spotlight?

@fschiettecatte
Copy link
Author

I did a few web searches around this. The answer to (1) is no, sorry. The only suggestions I saw for Spotlight indexing was to create the index manually or use the Spotlight privacy settings (though I think this relies on an Apple bug so may not work).

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