Samba-based TimeMachine with Big Sur

It’s been driving me nuts that file sharing between my linux server and my Mac has been flaky for quite a while with the mounting sometimes failing and TimeMachine having stopped working ages ago.

Therefore, I finally spent some time to dig deeper and to find a working solution. This has been quite complicated since most information on this online is outdated by now because either AFP is still used or the most recent changes through Big Sur aren’t considered.

Anyways, here’s a setup that works for me™ - may it help someone else who stumbles across this. My setup is the following:

  • Client with macOS Big Sur
  • Home networking with an internal custom domain
  • Server with Ubuntu 20.04.2
  • Storage located in a ZFS pool
  • Stock Samba 4.11.6
  • avahi-daemon 0.7

Samba

The first thing to set up would be Samba. Here, a post in the Apple Developer Forums helped to identify that different plugin configurations need to be made which the otherwise very helpful Samba Wiki didn’t mention.

What worked in the end is the following (incomplete) configuration:

[global]
min protocol = SMB2
vfs objects = acl_xattr catia fruit streams_xattr
fruit:nfs_aces = no
inherit permissions = yes

fruit:model = MacSamba
fruit:posix_rename = yes 
fruit:veto_appledouble = no
fruit:wipe_intentionally_left_blank_rfork = yes 
fruit:delete_empty_adfiles = yes 
fruit:metadata = stream

[TimeMachine]
path = /pool/TimeMachine
writable = yes
browseable = yes
read only = no
inherit acls = yes
fruit:time machine = yes

mDNS

Additionally, mDNS autodiscovery is desired and there have been hiccups in my previous configuration which are most likely related to the discovery mechanism or its configuration. Previously, I had configuration across multiple service files and now consolidated it into one.

Additionally, I’m now providing the fully-qualified domain name of the server in the host-name tag for both the _smb and the _adisk services. However, I’ve tested the configuration with and without that setting and it has been working fine either way.

Finally, my Mac didn’t show an icon in the Finder’s sidebar for XServe or RackMac models anymore. Through the helpful hint here, I found that models are defined in /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist and that MacPro7,1@ECOLOR=226,226,224 represents the rackmount MacPro for which a nice icon is included.

Here’s my complete smb.service that’s stored under /etc/avahi/services/:

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_smb._tcp</type>
    <port>445</port>
    <host-name>server.internal.domain</host-name>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=MacPro7,1@ECOLOR=226,226,224</txt-record>
  </service>
  <service>
    <type>_adisk._tcp</type>
    <txt-record>sys=waMa=0,adVF=0x100</txt-record>
    <txt-record>dk0=adVN=TimeMachine,adVF=0x82</txt-record>
    <host-name>server.internal.domain</host-name>
  </service>
</service-group>