Time Machine + Ubuntu + exfat

The Problem

Ubuntu 12.04 supplies the 2.2 versions of netatalk. This works well with native file systems, but using exfat is a different matter. Let's assume you've mounted a new exfat disk, defined like this in your /etc/fstab:

    UID=2268-9750 /media/4TB exfat owner 0 2

And configured netatalk that, just like in the excellent how to here.

    /media/4TB "Time Machine Backups" allow:username cnidscheme:dbd volsizelimit:200000 options:usedots,upriv,tm

Attempting to connect to it from your mac however, gives you this error on your Apple's screen:

Something wrong with the volume's CNID DB, using temporary CNID DB

But check your syslog back on your server, and you'll see this error 

Oct  9 10:02:47 work cnid_dbd[7576]: Error inheriting lockfile permissions: Function not implemented
Oct  9 10:02:47 work cnid_dbd[7576]: main: fatal db lock error
Oct  9 10:02:47 work afpd[7569]: read: Connection reset by peer
Oct  9 10:03:05  afpd[7569]: last message repeated 18 times
Oct  9 10:03:05 work afpd[7569]: transmit: Request to dbd daemon (db_dir /media/4TB/tm_backup) timed out.
Oct  9 10:03:05 work afpd[7569]: Reopen volume /media/4TB/tm_backup using in memory temporary CNID DB.

The Solution

There may be a work around, but the best solution seems to be an upgrade of netatalk, and some specific options in the conf file.

The Procedure

Download and build  the current version of Netatalk via the instructions on the main Netatalk site. 

Below is the prereq from the installation instructions on one line for ease

sudo apt-get install build-essential libssl-dev libgcrypt11-dev libkrb5-dev libpam0g-dev libwrap0-dev libdb-dev libavahi-client-dev libacl1-dev libldap2-dev libcrack2-dev systemtap-sdt-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev libevent-dev

Once you've done that, add this to your config. 

    >$ sudo vim /usr/local/etc/afp.conf

; Netatalk 3.x configuration file

; Global server settings

basedir regex = /home

[Time Machine Backups]
path = /media/4TB
vol size limit = 2000000
time machine = yes
unix priv = no

 Note: be sure to uncomment the ;[xxx] section or you'll see the error message "dsi_stream_read: len:0, unexpected EOF" in your syslog and get a mac login error

Note: the unix priv option seems to be important. If you don't add that, you'll hang your mac's finder (in my limited testing) and see this error in your server's syslog.

    setdirparam(/media/4TB/Allen’s MacBook Pro.tmp.sparsebundle/.): setdirunixmode: Function not implemented

If  you don't supply the vol size limit, you will eventually take up all the space on the drive.

Also - look at your mount point. The permissions matter. 

    $> ls -la /media
    drwxr-xr-x  1 root  root  131072 Oct  8 08:10 3TB

Notice that root owns this directory. You'll want to change that so you can create files as non-root. 

    sudo vim /etc/fstab
    UID=2268-9750 /media/4TB exfat defaults,noatime,user,uid=1000,gid=100 0 2