Installation AFP

iKnow-IT banner

logon to your Ubuntu server, and become "root". (e.g. via "sudo su -" )

Make your machine up-to-date:
# apt-get update
# apt-get upgrade

Remove old Netatalk if installed!
# apt-get remove netatalk

Install all necessary packages to build netatalk from the sources:
# apt-get build-dep netatalk
# apt-get install cracklib2-dev fakeroot libssl-dev

Now download and extract netatalk 2.2.0 from sourceforge:

# wget http://sourceforge.net/projects/netatalk/files/netatalk/2.2/netatalk-2.2...
# tar xfvj netatalk-2.2.0.tar.bz2
# cd netatalk-2.2.0

Configure, compile and install the extracted sources:
# ./configure –enable-debian –with-cnid-cdb-backend –disable-cups
# make
# make install

This will take a while and showing a lot of information but should complete without errors.

# vi /etc/default/netatalk

Search the following lines and make it like this:
ATALKD_RUN=no
PAPD_RUN=no
CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=no
A2BOOT_RUN=no

This will switch on Apple Filing Protocol (AFP) and meta information database.
Old AppleTalk, Printer server, Time synchronization and boot support are not needed.

# vi /usr/local/etc/netatalk/afpd.conf

Go to the last line and make sure it looks like this:

- -tcp -noddp -uamlist uams_dhx.so,uams_dhx2.so -nosavepassword

# vi /usr/local/etc/netatalk/AppleVolumes.default

Search for ~ in the file and remove it, otherwise all Linux home folders will be accessible as shared volumes. Add a share for TimeMachine and configure the maximum size of the virtual volume, like this:

/backup/TimeMachine TimeMachine allow:userXY cnidscheme:cdb options:usedots,upriv,tm volsizelimit:300000

Description of parameters:
/backup/TimeMachine – location for TimeMachine backups on the Linux machine
TimeMachine – Name of the network share
allow:userXY – allowed user (read/write access) – can be a comma separated list of users or groups – group names have a @ as prefix (like this: @users)
cnidscheme:cdb – type of database for meta information
options:usedots,upriv,tm - This share supports .Files/.Folders (usedots) with special privileges (upriv) and is time machine compatible ™
volsizelimit:300000 – Is the maximum size of the virtual volume (in this example: 300 GB)

Please read the man pages for all options, or search for AppleVolumes.default in the web.

Here is a another example for a simple network share:

/data/music MusicFiles allow:@users cnidbscheme:cdb options:usedots

This allows all people in the group „users“ read/write access to a share named „MusicFiles“.

Now it‘s time to restart netatalk:
# /etc/init.d/netatalk restart
(daemon netatalk = afpd)

Actually you won‘t see your shares on the Mac, because there is no service on the Linux machine that publishes them. We need to install the Avahi-daemon first:

# apt-get install avahi-daemon
# apt-get install libnss-mdns

Configure avahi:
# vi /etc/nsswitch.conf

Add the word mdns to the following line:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

Last step is to create service configuration file for publishing.
Create a new file /etc/avahi/services/afpd.service and copy/paste the following XML:

<?xml version=”1.0″ standalone=’no’?><!–*-nxml-*–>
<!DOCTYPE service-group SYSTEM “avahi-service.dtd”>
<service-group>
<name replace-wildcards=”yes”>%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=AirPort</txt-record>
<txt-record>sys=waMA=«Server MAC Address»,adVF=0×100</txt-record>
<txt-record>dk0=adVF=0×81,adVN=TimeMachine</txt-record>
</service>
</service-group>

A few modifications have to be made, before you save and close the new file.

In the field „model=AirPort“ you can choose between PowerBook, PowerMac, Macmini, iMac, MacBook, MacBookPro, MacBookAir, MacPro, AppleTV1,1, AirPort, Xserve. This will be the type of icon you will see in Finder on the Mac.

Replace «Server MAC Address» with the mac address of your Linux server in the field sys=waMA=«Server MAC Address»,adVF=0×100.
(You can determine it with ifconfig eth0 in the terminal)

The next line needs a bit more explanation:
dk0=adVF=0×81,adVN=TimeMachine

dk0= is the volume number. You can create more than one backup volume. Just create more txt-record entries in the file with dk1=… dk2=… and so on.
adVF=0×81 is the AirDisk flag, which tells OS X that this volume has support for TimeMachine.
adVN=TimeMachine is the name of the network share we configured in AppleVolumes.default

Finally we are ready to restart avahi:
# /etc/init.d/avahi-daemon restart
(daemon = avahi-daemon)

Hint: Avahi daemon automatically checks and reloads the service configuration file if something has changed

After a few seconds the icon of our new server should appear in Finder. Now configure Time Machine on the Mac. In the list of available volumes you should see the record „TimeMachine on serverXY“.

Initial backup will take very long. (In my case 8 hours!) – This is the same behavior as on a real Time Capsule.

I hope this guide will help you setting up a Linux based Time Machine and workgroup server.