Time Machine from the 1960 MovieWith the release of Apple’s Mac OS X 10.7 Lion, many people will notice that Time Machine fails to play nicely with their current Netatalk servers. There is a relatively simple solution for those of us who run Netatalk servers on Linux servers and NAS devices. However, if you’re relying on a NAS-vendor such as FreeNSD, you may need to wait for them to offer an update to ensure compatibility with Mac OS X 10.7. Apparently the major reason for this break in compatibility is a lack of a “replay cache”, which was introduced in AFP 3.3.

Anyhow, below I’ve created a simple guide on how to setup Netatalk 2.2 from source on most any Linux system. I am using Gentoo in this guide, but the basics should be the same on any other system. Currently Gentoo has not merged Netatalk 2.2 into portage, so we’ll have to download the source from Netatalk itself.

Download Netatalk 2.2 (Unstable): http://netatalk.sourceforge.net

Extract the contents of the file and cd to the directory:

# tar xvf ./netatalk-2.2-beta4.tar.bz2
# cd netatalk-2.2-beta4/

To build the binaries, first run the program ./configure in the source directory. This should automatically configure Netatalk for your operating system. If you have unusual needs, then you may wish to run:

# ./configure --help

to see what special options you can enable. The most used configure options are:
The most used configure options are:

  • –enable-[redhat/suse/cobalt/netbsd/fhs]
    This option helps netatalk to determine where to install the start scripts.
  • –with-bdb=/path/to/bdb/installation/
    In case you installed Berkeley DB in a non-standard location, you will have to give the install location to netatalk, using this switch.

Now run configure with any options you need. For Gentoo we’ll use the following configure options:

# ./configure --enable-gentoo --enable-zeroconf

The configure summary should look something like this:

Configure summary:
    Install style:
         gentoo
    AFP:
         AFP 3.x calls activated:
         Extended Attributes: ad | sys
    CNID:
         backends:  dbd last tdb
    UAMS:
         DHX     (PAM SHADOW)
         DHX2    (PAM SHADOW)
         RANDNUM (PAM SHADOW)
         passwd  (PAM SHADOW)
         guest
    Options:
         DDP (AppleTalk) support: no
         CUPS support:            no
         SLP support:             no
         Zeroconf support:        yes
         tcp wrapper support:     yes
         quota support:           yes
         admin group support:     yes
         valid shell check:       yes
         cracklib support:        no
         dropbox kludge:          no
         force volume uid/gid:    no
         Apple 2 boot support:    no
         ACL support:             yes

Now we couple and install Netatalk 2.2:

# make
# sudo make install

Edit the file to look something like my setup, but make sure to change YOUR_USERNAME to the name of the user on your system. The ~/.TimeMachine directory can be whatever you chose for your backup directory. It is important to add “tm” to the options section on  your Time Machine share, otherwise it will not work.

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

# The line below sets some DEFAULT, starting with Netatalk 2.1.
:DEFAULT: options:upriv,usedots

# The "~" below indicates that Home directories are visible by default.
# If you do not wish to have people accessing their Home directories,
# please put a pound sign in front of the tilde or delete it.
~/ "$u" allow:YOUR_USERNAME cnidscheme:dbd options:usedots,upriv
~/.TimeMachine "$u Backup" allow:YOUR_USERNAME cnidscheme:dbd options:usedots,upriv,tm

# End of File

Now edit the general AFP service config file to look like this:

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

# default:
- -udp -noddp -uamlist uams_randnum.so,uams_dhx.so,uams_dhx2.so -nosavepassword

Finally, edit the general Netatalk config file to look like this:

# vi /usr/local/etc/netatalk/netatalk.conf
# Netatalk configuration

#########################################################################
# Global configuration
#########################################################################

#### machine's AFPserver/AppleTalk name.
ATALK_NAME=`echo ${HOSTNAME}|cut -d. -f1`

#### server (unix) and legacy client (<= Mac OS 9) charsets
ATALK_UNIX_CHARSET='LOCALE'
ATALK_MAC_CHARSET='MAC_ROMAN'

#### Don't Edit. export the charsets, read form ENV by apps
export ATALK_UNIX_CHARSET
export ATALK_MAC_CHARSET

#########################################################################
# AFP specific configuration
#########################################################################

#### Set which daemons to run.
#### If you use AFP file server, run both cnid_metad and afpd.
CNID_METAD_RUN=yes
AFPD_RUN=yes

#### maximum number of clients that can connect:
AFPD_MAX_CLIENTS=20

#### UAMs (User Authentication Modules)
#### available options: uams_dhx.so, uams_dhx2.so, uams_guest.so,
####                    uams_clrtxt.so(legacy), uams_randnum.so(legacy)
AFPD_UAMLIST="-U uams_dhx.so,uams_dhx2.so"

#### Set the id of the guest user when using uams_guest.so
AFPD_GUEST=nobody

#### config for cnid_metad. Default log config:
CNID_CONFIG="-l log_note"

#########################################################################
# AppleTalk specific configuration (legacy)
#########################################################################

#### Set which legacy daemons to run.
#### If you need AppleTalk, run atalkd.
#### papd, timelord and a2boot are dependent upon atalkd.
ATALKD_RUN=no
PAPD_RUN=no
TIMELORD_RUN=no
A2BOOT_RUN=no

#### Control whether the daemons are started in the background.
#### If it is dissatisfied that legacy atalkd starts slowly, set "yes".
ATALK_BGROUND=no

#### Set the AppleTalk Zone name.
#### NOTE: if your zone has spaces in it, you're better off specifying
####       it in afpd.conf
ATALK_ZONE=@AFP

Now you should be able to get Netatalk up and running and start your backup (note: init.d may be rc.d on some systems).

# /etc/init.d/netatalk start

Also, on Gentoo systems, we will want to have this service start automatically at startup.

# rc-update add netatalk default

Now your formerly incompatible Netatalk installation should work with OS X 10.7 Lion’s Time Machine backup. However, if you’ve never setup your system for using Netatalk as a Time Machine backup server, you may want to follow these additional instructions.

OPTIONAL: If you have not setup a sparse disk image for time machine backups, follow these instructions.

On your OS X 10.7 machine, mount the Time Machine Share. It should show up in the “Shared” section of the sidebar in Finder. However, if it does not show up, you can manually mount the share by pressing COMMAND+K in the finder and entering your server details as follows:

Now open up Terminal.app and cd to the newly mounted volume.

# cd /Volumes/myBackup/

Now we’ll create a new sparse disk image for the Time Machine backup and enable support for network volumes in Time Machine. All of complicated stuff after “Time Machine” is just a script to automatically extract your machine’s local host name and ethernet MAC address.

# hdiutil create -size 512g -fs HFS+J -volname "Time Machine" `grep -A1 LocalHostName /Library/Preferences/SystemConfiguration/preferences.plist | tail -n1 | awk 'BEGIN { FS = "|" } ; { print $2 }'`_`ifconfig en0 | grep ether | awk 'BEGIN { FS = ":" } ; {print $1$2$3$4$5$6}' | awk {'print $2'}`.sparsebundle

# defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

Now configure Time Machine to use the mounted volume for backup and everything should work beautifully!