Apple Time Machine and Netatalk

Please note: This guide assumes you are using Snow Leopard. For Lion, things are a little different. I’m writing a new guide with Lion in mind but I haven’t got round to finishing it yet – the short version is: you need Netatalk 2.2 with its Avahi support built-in, and remove any manual Avahi service files you have created.

There are many guides on the Internet that deal with getting Apple’s Time Machine to back up to a network disk, however all of those that I managed to find rely on setting a hidden system preference to show unsupported disks – and hence don’t help with the problem of restoring from backup should the worst happen.

There is a way, though, to get Time Machine backing up to a Linux server without jumping through any hoops on the client. The backup volume just appears in the Time Machine preference pane, and the Mac OS X Install DVD’s restore mode also can see and restore from the network volume.

What you will need

I am basing these instructions on Debian Squeeze and Mac OS X Snow Leopard as that is what I’m running, however it looks like Netatalk 2.1 onwards has the necessary patches to support Time Machine (these implement the afp_syncdir and afp_syncfork commands in AFP 3.2).

You have to use AFP for Time Machine to be “supported”. It works with Samba but only in its unsupported configuration, and I ran into many issues when I used Samba – especially with backups becoming corrupted. I can only really recommend the use of Netatalk 2.1 or above for Time Machine.

You will also require avahi-daemon to be installed and running, as mDNS / Bonjour is required for the volumes to show up in the Time Machine preference pane.

Installing packages

Pull in the required packages:

aptitude install netatalk avahi-daemon

I prefer aptitude due to its dependency handling, but you can easily use apt-get or synaptic or whatever you wish.

Setting up Netatalk

Change your /etc/netatalk/AppleVolumes.default file to export the Time Machine volume. At the end of the file you’ll find a line that reads:

~/                     "Home Directory"

Change this to look a bit like this:

/srv/timemachine       "Time Machine"         options:tm

It’s very important to add the options:tm at the end of the line so that Netatalk enables various special options for Time Machine. I also recommend dedicating a filesystem entirely to Time Machine (e.g. /srv/timemachine should be its own mountpoint). Additionally, Apple recommends not to use the volume for anything but Time Machine due to the way locks are used (see TMNIS, below).

Finally, restart Netatalk:

/etc/init.d/netatalk restart

Configuring Avahi

By default Avahi advertises your server’s name as its hostname, which by convention on Linux is all lowercase. If you wish to alter the name of the server as advertised, you can edit /etc/avahi/avahi-daemon.conf and change the host-name= line in the [server] section to whatever you desire. This name will show up in the Finder’s list of Bonjour shared servers in the sidebar. Don’t forget to restart Avahi if you do this.

Next we need to set up an Avahi service file to advertise our Time Machine disk. Create /etc/avahi/services/afpd.service and paste in:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<name replace-wildcards="yes">%h</name>



 <txt-record>sys=waMA=«MAC Address»,adVF=0x100</txt-record>
 <txt-record>dk0=adVF=0x83,adVN=Time Machine</txt-record>


Note: You must replace «MAC Address» above with your server’s MAC address. You can find this out using ifconfig eth0 or ip link list dev eth0. You should also replace whatever volume name you used in AppleVolumes.default for the adVN= field if you didn’t use “Time Machine”.

The service definition advertises 3 capabilities: AFP over TCP, which is required for Time Machine and which Netatalk provides, a Device Info virtual service which in this case tells Mac OS X that the device is in fact an Xserve (optional, but gives your server a pretty icon in the Finder) and the all-important AirDisk service with Time Machine flags.

The adVF=0x83 field are the AirDisk flags which tell Mac OS X that Time Machine is supported on this volume. If you wish to expose additional volumes, duplicate the dk0= line but call it dk1=, dk2=, etc…

Avahi automatically reloads the contents of the services file each time it changes, so you should not need to restart Avahi for this to take effect.

Setting up Time Machine

The above should be enough for the volume to appear in the Time Machine control panel. However, as my Time Machine backups have evolved over time I don’t know if this is enough to create a new backup from scratch. If this doesn’t work for you please let me know so I can update the instructions as necessary!


HowTo: Make Ubuntu A Perfect Mac File Server And Time Machine Volume – The first guide I followed to set up netatalk. This uses the unsupported method and has some outdated instructions about having to recompile Netatalk.

Time Machine Network Interface Specification (TMNIS) – The official Apple doc on what’s required for Time Machine to work.

Time Machine / Time Capsule Success! (no afp_fsyncfork yet) – A thread on netatalk-devel describing how to set up Time Machine with the mDNS configuration.

Time Machine on the FreeNAS forum. This discusses various combinations of the adVF parameter on the sys= line that I had to adjust.

32 thoughts on “Apple Time Machine and Netatalk

  1. Nice write-up. Two questions though:

    1) You mention “If you wish to expose additional volumes, duplicate the ad0= line but call it ad1=, ad2=, etc…” Yet I don’t see an ad0 line. Is the dk0 line a typo?

    2) How is the volume size limited? I guess the recommendation is to use a separate volume on its own mount point, so it would just use up to the entire device properly? Or is there a way to place limits and use one device…


  2. James – You’re right, ad0 is a typo. I’ve now fixed this.

    You can limit the size of the AFP volume with the limitsize:value in bytes volsizelimit:size in MiB option after options:tm, e.g. options:tm volsizelimit:209715200. This will allow you to use the same partition for other things, but I’m still not sure how well that interacts with storing files on the same AFP share. Note I haven’t done this myself at all, just reading the documentation.

  3. Just wanted to say thanks for this guide. I’ve set up avahi and netatalk before, but I didn’t know about service definitions. This guide was nice and to-the-point, and saved me some time. Keep up the good work!

  4. Hi,

    I think limitsize does not take parameters.
    Check: man AppleVolumes.default (5)

    Limit disk size reporting to 2GB. This can be used for older
    Macintoshes using newer Appleshare clients.


  5. Joris, you are right, that’s indeed what the manpage says along with the documentation lower down in AppleVolumes.default. However, at the top of that file, it also shows up as [limitsize:value in bytes]. This is what confused me, the option is in fact called volsizelimit

    From the config file: volsizelimit -> size in MiB. Useful for TimeMachine: limits the reported volume size, thus preventing TM from using the whole real disk space for backup. Example: “volsizelimit:1000” would limit the reported disk space to 1 GB.

  6. A few things that are important to note:
    the loopback network adapter is needed. (I started from a fresh debootstrap and never configured this)
    The timemachine user needs to have write access on the directory. I recommend using the sticky bit.
    Logs on debian squeeze will appear is /var/log/syslog

  7. Pingback: 10 Configuration de Netatalk | Chez Ti nicO

  8. Is the mac address in 00:00:00:ef blah? Or is it 0000ef??

  9. Have you experimented with resizing the partition after already backing up there?

    Here is my setup: I set a dedicated LVM Volume with aprox 360GB on it. Formated with ext4, mounted on /mnt/tm and exported with netatalk, as per your instructions. It appreared on the mac finder (by the way, clicking on it in finder does nothing), and timemachine found it as a supported volume without any sort of hacks (I turned off the unsupported volumes plist flag). The first time it tried to backup, it correctly set up all the environment, created the sparsebundle, the control files, etc. Backing up to it is working just fine and it really feels like it’s a timecapsule equivalent.

    Now the resizing: after some days happily backing up to that server, I gave a second thought to the size of the partition and decided to make it smaller. Stopped netatalk, unmounted the volume, ran resize2fs on it and made it down to 200MB. At this time, only about 70GB were really being used, leaving still 130GB free after resize. All well. Mounted the volume again, started netatalk again, and initiated a timemachine backup.

    It ran successfully, as I expected. But, while it was backing up and the network drive was mounted on my desktop, I tried to see how much space left the mac was thinking there was on the volume. With “Get Info” (right click on drive icon), it says “130GB free of 360GB total”. If I open time machine preferences, it says: “Available: 130GB of 200GB”.

    Two conflicting informations about the size of the drive. My fear is what exactly will happen when it becomes full, and if I should format and start over again. And if in the future I would be able to do the opposite, make it bigger.


  10. Andre,

    It’s probably caused by the sparsebundle and the networkshare having different sizes. When you adjust the maximum size of the sparsebundle in disk utility, the difference should disappear.

    Hope this helps.

  11. Hi Chris,

    Thanks for the nice write up. Did you try getting this working on OS X Lion Dev preview? Seems like the AFP authentication options have changed since Snow Leopard. It has been verified that Lion is able to connect to a Linux host running netatalk 2.1 (and onwards) supporting the DHX2 UAM in afpd.

    However, when setting my network drive (through AFP) as my Time Machine backup disk it fails with an error, saying “The network backup disk does not support the required AFP features.”

    Have you managed to get this work on Lion Dev Preview by any chance? Would be great to know since I bought the drive in order to use it for that exact purpose.

    — Attila

    • Attila, as Jamie mentioned you will need netatalk 2.2 for Lion support. This will bring many improvements including registering Time Machine volumes with avahi by itself without requiring manual crafting of a services file. Netatalk 2.2 is not yet final, though I have been using it since the early betas and is quite stable now. The latest release as of this writing is 2.2-beta4, though -rc1 or even final seem to be right around the corner.

  12. @Attila

    To the poster above this. I’m in the exact same boat as you! My third party (Iomega) NAS drive doesn’t run netatalk 2.2 which has the required AFP features for Time Machine in Lion. It seems it was ok in Snow Leopard, but in Lion ‘TM Lock Stealing / Server Reply Cache’ are mandatory for Time Machine. The solution is installing netatalk 2.2 on the NAS drive, however i’m not good with this stuff.

  13. Thanks, this article saved my bacon. I just replaced a bad disk in my iMac, and planned to restore from backups. It turns out I was missing the adisk service in my avahi config, and although I’d managed to configure Time Machine to do backups just fine, the MacOS X Installer was not finding the device and I couldn’t restore. I added the extra service (and correct mac address), and I was back in business.


    • Jim, yes, that should be no problem. I do it using two separate time machine volumes for my two Macs, though you should be able to do it with just one – I just haven’t tried it.

  14. @Chris Boot

    I don’t suppose you have an ARM build of Netatalk 2.2 beta 4 handy, do you?
    I can’t seem to cross-compile it on my Mac or on-device, and i’d kill to get my hands on it.
    I just want Time Machine again in Lion 🙁 lol


  15. thanks for your response! I am very glad i found your article. again, thank you. you have made me learn how to make my own version of time capsule, practically for free! linux is the greatest operating system ever i think! again thank you very very much!

  16. I have another question, does the drive or partition need to be a specific file system, or can it just be ext3 or ext4 or anything? thank you.

  17. Pingback: How to build a 8 TB RAID5 encrypted time capsule for 500 Euros « funky code

  18. It lasted 2 days!!! Once, I installed Lion, it broke it. Then I read through the comments and realized that I need to install netatalk 2.2. Once I did that, now OSX complains with the following message “The server may not exist or it is unavailable at this time. Check the server name or IP address, check your network connection, and then try again.”

    I am able to ping to my ubuntu machine. When I use avahi browser, I can see the TimeMachine service listed. Please help!

  19. Hi,

    I got the error “The operation couldn’t be completed. (OSStatus error 2.)” when I’m trying to choose my share as backup drive for Time Machine in System Preferences.

    Any ideas?

  20. Thanks,

    10 hours of hard work and 4 corupt vmware ubuntu’s, 16 different how to’s
    but this is the whon that worked for me

    ubuntu desktop 10.04 netatalk 2.2 beta 4 and new macbook pro lion

  21. Its working now. It was because Netatalk 2.2 doesn’t need avahi to advertise it anymore, so I was getting a name clash if I ran both.

  22. Finally! Been working on this for two days following different older guides and this is the first guide that managed to help me.

    Thanks a thousand!

  23. Pingback: Project “My Time Capsule” – or – How to build a Time Machine and workgroup server | Göris blog

  24. Pingback: Making your AFP server more Time Machine friendly «

  25. Wow, like other are saying, I’ve tried tons of other tutorial and this one is the only one that works. Kudos on the great work! This is a real life saver.

  26. Pingback: Netatalk : Back to the Mac ! « Chez Ti nicO – le blog

Comments are closed.