Apple Time Machine on Server running Gentoo Linux

This guide is about how to add Apple Time Machine to a Server running Gentoo Linux. Since Apple's backup tool only supports thier own filesystem HFS+, we start with installing it and preparing the disk to be able to create the Time Capsule on it later.

emerge -avq diskdev_cmds
mkfs.hfsplus -v Backup /dev/md2    
mkdir /mnt/disks/backup
# optional: adding a mount point to your fstab
echo "/dev/md2      /mnt/disks/backup   hfsplus noatime     0 1" >> /etc/fstab

Futher we need to install two services - netatalk and avahi-daemon. Netatalk provides Apple's network filesystem protokoll, which is needed since using Time Machine over network requires afs. The Avahi Daemon is used to make Netatalk available in the network.

#  !!! NOTE make sure your use flags contains avahi
echo "net-fs/netatalk avahi pgp samba ssl utils" >> /etc/portage/package.use
echo "net-fs/netatalk ~amd64" >> /etc/portage/package.keywords
emerge -avq netatalk
# optional add both service to the autostart
rc-update add avahi-daemon default
rc-update add netatalk default

The next step is to configure netatalk that OS X could access the network drive by editing /etc/afs.conf as follows. Make sure the user(s) specified under valid user exists on the server. If not, create it. A client will need it to access the afs network drive.

[Global]
; Global server settings
; uam list = uams_dhx.so,uams_dhx2.so,uams_dhx2_passwd.so
uam list = uams_dhx.so,uams_dhx2.so
save password = no

[default_for_all_vol]
file perm = 0664
directory perm = 0774
cnid scheme = dbd
valid users = phgamper

; [Homes]
; basedir regex = /xxxx

; TMAFPVoume could be replaced by a name of your choice
[TMAFPVolume]
time machine = yes
path = /mnt/disks/backup/timecapsule
vol size limit = 1000000

Once we finished, we create the Time Capsule for the specified user(s). As mentioned above a client has to authenticate when connecting to the network file system. Thus the user has to own or at least has read, wirte and execution rights to the folder, where the capsule will finally be stored.

mkdir /mnt/disks/backup/timecapsule
chown phgamper /mnt/disks/backup/timecapsule

Finally we are finish with configuring the server and could go on starting netatalk and avahi-daemon.

/etc/init.d/avahi-daemon start
/etc/init.d/netatalk start

Now the server is ready and should appear in the Time Machine's system configuration. If not, the following fix on your client should work.

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

Further Reading

PG4gdWVycz0iem52eWdiOj9maG93cnBnPWN1dG56Y3JlLnB1Jm56YztvYnFsPSUwTiUwTnVnZ2NmOi8vY3V0bnpjcmUucHUvZ2JjdnBmL295YnQvMjAxNC0wOS0yNF8xMTA5X2d2enJ6bnB1dmFyIj48diBweW5mZj0ic24gc24tMmsgc24tcmFpcnliY3ItZmRobmVyIGpiaiBvYmhhcHJWYSIgcW5nbi1qYmotcXJ5bmw9Ii42ZiIgZmdseXI9Iml2ZnZvdnl2Z2w6IGl2ZnZveXI7IG5hdnpuZ3ZiYS1xcnlubDogMC42ZjsgbmF2em5ndmJhLWFuenI6IG9iaGFwclZhOyI+IDwvdj4gPC9uPg==