Skip to content

Instantly share code, notes, and snippets.

@costajoao
Last active April 5, 2020 06:13
Show Gist options
  • Save costajoao/f64ef2bdd65c10f84f67ac210a621227 to your computer and use it in GitHub Desktop.
Save costajoao/f64ef2bdd65c10f84f67ac210a621227 to your computer and use it in GitHub Desktop.
Install Ubuntu (arm64) 18.04 LTS as a TimeMachine Server

Ubuntu (arm64) as a TimeMachine Server

Apple now use SMB for time machine backup, but it require F_FULLFSYNC which is not supported by most SMB servers* 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 (arm64) 18.04 LTS

1. Install dependencies

sudo apt update
sudo apt upgrade -y
sudo apt install -y 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 \
         libicu-dev libntirpc-dev asn1Parser

2. Download and install samba (4.12.0)

wget https://download.samba.org/pub/samba/stable/samba-4.12.0.tar.gz
tar -zxf samba-4.12.0.tar.gz
cd samba-4.12.0/
echo "^samba4.rpc.echo.*on.*ncacn_np.*with.*object.*nt4_dc" >> selftest/knownfail

CFLAGS="-I/usr/include/tirpc"          \
./configure                            \
    --prefix=/usr                      \
    --sysconfdir=/etc                  \
    --localstatedir=/var               \
    --systemd-install-services         \
    --enable-fhs                       \
    --without-ad-dc                    \
    --without-ads                      \
    --without-ldap                     &&
make && make install

3. Configure samba

sudo nano /etc/samba/smb.conf
[global]​
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​
​
[TimeMachine]​
path = /Volumes/TimeCapsule​
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​

4. 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/
chmod +x nmbd smbd
sudo update-rc.d nmbd defaults
sudo update-rc.d smbd defaults
sudo update-rc.d samba defaults

5. Increase open file number limit

ulimit -n 32768
sudo nano /etc/security/limits.conf

Add line below:

*                soft    nofile          32768

6. Optional: Increase the band size of sparsediskimage

I've increased the band size to 256MB. Not sure if the open file limit 32768 is enough or not

Good luck!

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