Time Machine

I decided to set up Time Machine backups for my new Macbook Air using my FreeBSD based file server. This server was already configured to serve files over AFP and Samba and I had multicast DNS set up on it. The Time Machine setup was really an incremental improvement of the existing functionality.

There are a lot of guides around describing this kind of setup and a lot of them are out of date (not applicable to OSX 10.7). I found that using the latest version of Netatalk and Avahi along with a little bit of bait-and-switch for the disk image itself gave a satisfactory outcome.

Note: This guide assumes you are running OSX 10.7 and using a FreeBSD 8.2 server.

First thing to do was to update my FreeBSD ports collection and then do a full port upgrade. This took quite a long time (I am a bit lax about keeping ports up to date on this machine).

The relevant commands:

# portsnap fetch extract update
# portmanager -u

If you don’t have portmanager installed:

# cd /usr/ports/ports-mgmt/portmanager && make install clean

Wait a long time, occasionally selecting configuration options at random such that you can’t just leave it running. Oh and try and make sure you avoid anything which selects an optional dependency on gtk or X11 to avoid pulling in the entire universe…

At this point I found some conflicts and had to remove some of the conflicting ports manually using pkg_delete, these were:

# pkg_delete ghostscript8-nox11-8.71_8

# pkg_delete howl-1.0.0_1
# pkg_delete bash3-3.2.51

This is probably very specific to the state of my ports collection however!

When ports are up-to-date the versions of Netatalk and Avahi ought to be (or better):



Netatalk 2.2 in particular is needed to support some of the functionality Time Machine requires.

Configure /usr/local/etc/AppleVolumes.default:

/ "" options:noadouble,tm allow:,


/store "store" options:noadouble,tm allow:bob,luke

(The “tm” option indicates to OSX that this is a valid Time Machine backup share so it’ll appear in the Time Machine list without having to use the infamous “defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1” hack.)

Configure /usr/local/etc/avahi/avahi-daemon.conf

-- use-ipv6=no

++ use-ipv6=yes

Create /usr/local/etc/avahi/services/afpd.service with contents:



(This will mean the file share shows up with a nice Xserve icon in the Finder and elsewhere. You don’t need to explicitly set up Avahi to advertise AFP since Netatalk 2.2 can automatically register with Avahi – Make sure you configure Netatalk with Avahi support (same for Samba) and if not switch to the port directory in question and do make config to change it).

You’re pretty much done for server configuration at this point. Restart all the applicable services:

# /usr/local/etc/rc.d/dbus restart && /usr/local/etc/rc.d/avahi-daemon restart && /usr/local/etc/rc.d/netatalk restart

On the client side, enable Time Machine and select your file store under “Select Disk”. By default it’ll create a sparsebundle as big as the containing volume (obviously being sparse it’ll only take up space as you start to back up to it). Obviously you will want some control over how big it gets. For example my Mac only has 120GB of disk space so I don’t want the backup set to grow to more than 300GB (to permit some storage of history of files etc.) There isn’t by default a way to easily specify how big the disk image should grow via the UI so this requires a bit of trickery. Also, if you want to enable encryption for your backup you also need to perform some magic.

Say your Mac is called neutrino, like mine, Time Machine will create a sparsebundle disk image at the root of your file share called “neutrino.sparsebundle”. This will by default be unencrypted and as big as the file store. After this is created Time Machine will start to backup to it. Interrupt the backup at this point (make sure the image has been created and that it’s on the “backing up” stage) and disable Time Machine.

Rename “neutrino.sparsebundle” to “neutrino-old.sparsebundle”. Open the disk image in Disk Utility. Create a new sparsebundle in Disk Utility with the settings:

Name: Time Machine Backups


Format: Mac OS Extended (Case-sensitive, Journaled)

Encryption: 128-bit AES encryption (optional, but why would you want an unencrypted backup?!)

Partitions: Single Partition – Apple Partition Map (default)

Image Format: sparse bundle disk image

Save it as “neutrino.sparsebundle” under the root of your Time Machine file share.

Next step is the clever bit. Make sure you have both old and new sparsebundles mounted in Disk Utility and then restore the “Time Machine Backups” volume from the old one onto the new one, replacing the existing (empty) volume.

When this process completes delete the old sparsebundle and unmount the new one. Time Machine can then be re-enabled and will use the new encrypted and size-limited sparsebundle to perform backups to in future.

You may find you need to use the MAC address trick to get Time Machine to recognise that your sparsebundle is the correct one. If after the steps above it still tries to create a new bundle when performing the backup rename the “neutrino.sparsebundle” file to “neutrinoYOURMACADDR.sparsebundle”. So for example if the MAC address of en0 on your machine happens to be: 00:11:22:33:44:55 then you’d rename the file to: “neutrino001122334455.sparsebundle”. Time Machine ought to rename this to just “neutrino.sparsebundle” when it runs the first time.

It would sure be nice if Apple allowed us to configure these kind of things in a less arcane way, but it works nicely once it’s set up.

Useful links: