Using OS X Time Machine with NFS

Storing backups on NFS is not an officially supported by Apple, but is quite easy to do.

NFS server side

The server can be any BSD or Linux. The first thing to do is to check the Unix user id on the Mac and NFS server (you can find it by typing id in the terminal). It is best if the user id on both systems is the same (less file permissions problems…).

You can create a new user account with a specific id by:

(-m creates home directory, -u specifies user id)


I will not make this post a generic NFS-howto, so I will only stick to the relevant parts of setting up NFS.

/etc/exports file contains directories the server makes available to other clients over the network. It should have something like this:

The IP should be the Mac’s LAN IP.

Mounting NFS share on OS X

After restarting NFS services on the server you can try mounting the share manually to see, if the settings and permissions are okay. Mount command:

If no error messages are shown, then mount succeeded and any file created in /private/nfs/ should be visible on the server.

Automounting at startup

First: get root privileges by using sudo su, then you have to create a file called /etc/auto_nfs with the following contents:

Second: add this single line to /etc/auto_master:

Then you can test if it works:

Great, now the NFS directory should be automatically mounted at every startup.

Creating a sparse bundle

Time Machine can only store backups on a HFS+ filesystem. To use it over NFS you have to create a virtual filesystem in the NFS directory – it is called a sparse bundle. The HFS+ sparse bundle is a group of files (8MB each), that can be mounted by OS X and used as a regular hard drive (it is similar to a .dmg file). It is called “sparse”, because you specify the size of virtual disk at the moment of creation (you can expand it later, but you can not shrink it), but it is as large as the data within (ie. a 500GB sparse bundle with 10GB of data inside will occupy roughly 10GB of real disk space).

This command creates a sparse bundle (run as normal user):

The size (500g here), should be at least the size of the disk you have in the Mac. If it is larger, then Time Machine will be able to store more history. An empty sparse bundle occupies about 500 megabytes.

Automounting the sparse bundle at startup

This was the most tricky part to figure out. Some tutorials suggest using AppleScript. I did this using Automator.

Start Automator, create a new application, add a shell script component with the following code:

You can test the app directly in Automator (button in upper right corner of the window) – a disk called TimeMachine should appear on the desktop.

After saving this app somewhere on the disk you can add it to login components (drag the app from Finder to System Preferences -> Users&Groups -> Login items).

Time Machine configuration

Final steps:

First line sets the destination disk – the sparse bundle mounted by Automator, second line disables local snapshots, third enables Time Machine. That’s all 🙂

Local snapshots are a kind of partial backups that are stored on the local drive, they can speed up making backups and restores if the Mac was not connected to the NFS server. Local snapshots consume some disk space.