Smb/samba For Time Machine Backup


Apple now use SMB for time machine backup, but it require F_FULLFSYNC which is not supported by most SMB server like Windows server or current stable version of samba.

Thanks to latest version of samba, now time machine can work with linux / unix server. But it seems there isn't so much step by step guidance for it so it caused me lots of time to build a linux server for samba.

Environment: Ubuntu server 18.04.1 LTS on Hyper-V (I suppose it should be the same on other VM or physical machine).

1. Create the virtual machine: generation 2, enable secure boot with template of Microsoft UEFI Certificate Authority, 1GB, two hard disk (10GB for OS, 500GB for time machine data). The RAM need to be 1GB for installation of Ubuntu 18.04, but it can be smaller (like 0.5GB) to run.

2. Install Ubuntu 18.04.1 LTS.

3. Install dependencies
apt-get update[/INDENT]
apt-get install acl attr autoconf bind9utils bison build-essential debhelper dnsutils flex gdb libjansson-dev libacl1-dev libaio-dev libarchive-dev libattr1-dev libblkid-dev libbsd-dev libcap-dev libcups2-dev libgpgme-dev libldap2-dev libncurses5-dev libpam0g-dev libparse-yapp-perl libpopt-dev libreadline-dev nettle-dev perl perl-modules pkg-config python-all-dev python-crypto python-dbg python-dev python-dnspython python3-dnspython python3-dev xsltproc zlib1g-dev

5. Download and install samba (4.8.4)
tar -zxf samba-4.8.4.tar.gz
cd samba-4.8.4/
./configure --without-ad-dc --enable-fhs --prefix=/usr --sysconfdir=/etc --localstatedir=/var --systemd-install-services --without-ads --without-ldap
make && make install

6. Configure samba
sudo vi /etc/samba/smb.conf
server role = standalone server​
passdb backend = tdbsam​
obey pam restrictions = yes​
unix password sync = yes​
security = user​
durable handles = yes​
fruit:aapl = yes​
fruit:time machine = yes​
fruit:advertise_fullsync = true​
path = /data​
comment = Time Machine Backup Disk​
browsable = yes​
writable = yes​
create mode = 0600​
directory mode = 0700​
kernel oplocks = no​
kernel share modes = no​
posix locking = no​
vfs objects = catia fruit streams_xattr​

sudo mkdir /data
7. Launch samba as system service: copy the attached files (nmbd, smbd, samba) to /etc/init.d/ (or just type :) ), and register service.
cd /etc/init.d/[/INDENT][/INDENT]
[INDENT][INDENT]chmod 755 nmbd smbd samba[/INDENT][/INDENT]
[INDENT][INDENT]sudo update-rc.d nmbd defaults[/INDENT][/INDENT]
[INDENT][INDENT]sudo update-rc.d smbd defaults[/INDENT][/INDENT]
[INDENT][INDENT]sudo update-rc.d samba defaults
8. Optional: Add a group for samba
[INDENT][INDENT]sudo groupadd samba[/INDENT][/INDENT]
[INDENT][INDENT]sudo usermod -a -G samba username[/INDENT][/INDENT]
9. Recommended: Mount data disk
sudo fdisk /dev/sdb[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT](3 returns for the 3 default options)[/INDENT]
[INDENT][INDENT]sudo mkfs.ext4 -L Data /dev/sdb1[/INDENT][/INDENT]
[INDENT][INDENT]sudo vi /etc/fstab
Add line below to the end of the file​
/dev/sdb1 /data ext4 defaults 0 2​
sudo mount -a[/INDENT][/INDENT]
[INDENT][INDENT]sudo chown root:samba data/[/INDENT][/INDENT]
[INDENT][INDENT]sudo chmod 770 data/
10. Increase open file number limit
ulimit -n 32768[/INDENT][/INDENT]
[INDENT][INDENT]sudo vi /etc/security/limits.conf
Add line below​
*                soft    nofile          32768
11. Optional: Increase the band size of sparsediskimage (I increased the band size to 256MB. Not sure if the open file limit 32768 is enough or not)
12. Mount the disk on macOS: Finder -> Go -> Connect to Server, smb://servername or serverip/, select the network disk in system preferences, enjoy.

  1. Package Dependencies Required to Build Samba
  2. Build Samba from Source
  3. [NAS] high Sierra Time Machine
  4. Run automatically program on startup under linux ubuntu [closed]


  • Time Machine.jpg
    Time Machine.jpg
    94.3 KB · Views: 18
    3.3 KB · Views: 54
Last edited:
OK, I tried to use scripts from packaging/systemd dir in source but had numerous issues with them. So I used samba-4.7.5 + fullsync patch instead and everything is working flawlessly.
OK, I tried to use scripts from packaging/systemd dir in source but had numerous issues with them. So I used samba-4.7.5 + fullsync patch instead and everything is working flawlessly.
Sorry friend, didn't check it for several months. Just uploaded the 3 files. The only function is to make smbd and nmbd run as system services automatically.
BTW, the stable release of 4.8.4 is available now.