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 server settings
; uam list =,,
uam list =,
save password = no

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
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 TMShowUnsupportedNetworkVolumes 1

Further Reading


Using Polybox on Gentoo Linux

The following guide shows how to run polybox, a dropbox like cloud provided by ETH Zurich, on Gentoo Linux.

Since polybox is not in the portage tree, we have to download the packages from a diffrent distro. Debian packages are easy to extract, thus we use the latest *.deb from

  • libpolyboxsync-dev
  • libpolyboxsync0
  • polybox-client

The next step is to extract the *.deb packages using the following command

ar x *.deb
tar xvf data.tar.gz

Then we move the polybox binary, its dependencies and its config file to the right location

cp -r etc/polybox/ /etc
cp -r usr/include/ /usr/local/
cp -r usr/share/ /usr/local/
cp -r usr/bin/ /usr/local/
cp usr/lib/x86_64-linux-gnu/* /usr/lib/
mkdir /usr/lib/x86_64-linux-gnu/
cp -r usr/lib/x86_64-linux-gnu/polybox/ /usr/lib/x86_64-linux-gnu/

After that /usr/lib64/ should look as follows.

root@host user # ls -al /usr/lib64/ | grep poly
lrwxrwxrwx   1 root root       19 Sep 19 22:06 ->
lrwxrwxrwx   1 root root       23 Sep 19 22:06 ->
-rw-r--r--   1 root root  1109640 Sep 19 22:06

Now make sure all further dependencies available in portage are installed. Normaly the qtkeychain is the only missing package.

emerge -avq qtkeychain

That's it! Polybox could be started e.g. using xfce4-application-finder

Further Reading:


Adding power management commands to i3 using polkit

As there are no power management commands, when using i3 we could add them as follows. First we make sure polkit is installed, to allow unprivileged users to run power management commands. Then we create the following script, that contains the polkit commands, place somewhere in $PATH, for example in /usr/bin/i3exit and make sure the script is executable.



case "$1" in
        i3-msg exit
        dbus-send --system --print-reply --dest="org.freedesktop.UPower" \
        /org/freedesktop/UPower org.freedesktop.UPower.Suspend
        dbus-send --system --print-reply --dest="org.freedesktop.UPower" \
        /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
        dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" \
        /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
        dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" \
        /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
        echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
        exit 2

Now we add the following lines to ~/.config/i3/config. Once completed we will be presented with a prompt whenever we press $mod+paus

set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$mode_system" {
    bindsym l exec --no-startup-id i3exit lock, mode "default"
    bindsym e exec --no-startup-id i3exit logout, mode "default"
    bindsym s exec --no-startup-id i3exit suspend, mode "default"
    bindsym h exec --no-startup-id i3exit hibernate, mode "default"
    bindsym r exec --no-startup-id i3exit reboot, mode "default"
    bindsym Shift+s exec --no-startup-id i3exit shutdown, mode "default"

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
bindsym $mod+Pause mode "$mode_system"