Skip to content

Instantly share code, notes, and snippets.

@fschiettecatte
Last active March 19, 2024 15:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fschiettecatte/02d61e3d36c5f8d36bd45586fc5d0dc7 to your computer and use it in GitHub Desktop.
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 switched from using Netatalk to Samba for file access from MacOS to linux.

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

    # Password backend
    passdb backend = tdbsam

    # Always sync to disk (optional)
    # For some reason 'sync always = yes' does not play well with Ventura 13.4 and Samba 4.17.5
#    strict sync = yes
#    sync always = 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 = SMB2
    ea support = yes
    vfs objects = fruit streams_xattr
    fruit:metadata = stream
    fruit:model = MacSamba
    fruit:veto_appledouble = no
    fruit:nfs_aces = no
    fruit:posix_rename = yes
    fruit:zero_file_id = yes
    fruit:wipe_intentionally_left_blank_rfork = yes
    fruit:delete_empty_adfiles = yes

    # Use extended POSIX ACLs
    inherit acls = yes

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

    # Linux supports kernel oplocks
    kernel oplocks = 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.

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

[default]

# SMB client signing is not required
signing_required=no


# How to disable SMB 1 or NetBIOS in macOS
# https://support.apple.com/en-us/HT211927

# Require SMB2/3
# 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=6

# No SMB1, so disable NetBIOS
port445=no_netbios


# Configure SMB Multichannel behavior
# https://support.apple.com/en-us/HT212277

# Disable multichannel support
# mc_on=no

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


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