Setting up Apple Time Machine via SMB


If you already have a file server, chances are you want to backup your Mac to that rather than to a dedicated Time Machine attached/Apple remote disk.


  • Apple only support Apple Timemachine solutions. This is partly because: reliable backup + networks + 3rd party products + non-technical users = trouble. However once it is setup it seems to work fine.
  • SMB is a much slower protocol than NFS and AFP. Ie your backups and restores are slower. AFP might be a better choice if available.


I also use rsync for backups. Rsync is much lower level, command line technology but otherwise is just as good if not better ( eg it works across many platforms). I may oneday create a gui for it but for now there is a great tutorial here: (external link)

For my purposes SMB == SMBFS == Samba == CIFS

These notes are the result of my own research plus the discoveries of nameless others on the net (thankyou).

My Environment

  • Server: Solaris 10: SunOS blackhole 5.11 NexentaOS_20090926 i86pc i386 i86pc Solaris
  • Client: Mac OS X Leopard: 10.5.8

Step Summary

  1. Setup the share from the server
  2. SMB mounts on OS X
  3. Timemachine preparations
  4. Configuring Timemachine

Step Details

1) Setup the share from the server

Note: Time Machine only works in the top level share of the directory. So to get the backups into a particular directory you need to explicitly share that directory.

2) SMB mounts on OS X

3) Time Machine Preparations

3a) Let Time Machine see "UNSUPPORTED" network disks.
defaults write TMShowUnsupportedNetworkVolumes 1

Some people suggest that "sudo defaults...." is needed. My experience is that sudo is not needed when logged in as a user who has Admin rights.

3b) Mac hostname:
There are several ways to do this. They all should produce consistent results. YMMV.

Hostname examples
bigmac:~ kim$ hostname -s	(-s just omits the domain name)

bigmac:~ kim$ scutil --get ComputerName

Hostname Notes
  • Formal computer names should only ever consist of [A-Za-z0-9_-] (there are standards for this). I recall some debate over - or _ (I forget which) but it seems mostly academic. In particular no spaces!! Given that Time Machine uses "_" to separate parts of a filename there is a chance that having an "_" in your hostname could cause problems.
  • I have seen several comments that suggest the Mac computer name should be no more than 8 characters for Time Machine to work. I have not tested this, YMMV.
  • The name of your Mac system disk in Finder is an arbitrary name (even if you've set it to your computer name).
  • There are similar scutil keys LocalHostName and HostName. Interestingly the latter returns "not set" on my machine. LocalHostName is affected by "Computer Name" set in the System Preferences. Spaces are replaced with "-" as shown in the comment under the Preferences typein.
  • I forget how my hostname was set, but if using System Preferences -> Sharing "Computer Name", you should probably reboot and retest before continuing.

3c) Mac ethernet id (MAC)
$ ifconfig en0 | grep ether
	ether 00:1b:63:xx:xx:xx

Your result should be similar to this with different values probably just in the xx
Time Machine uses the internal ethernet MAC even if you happen to connect via Airport. It's used like a serial number so that multiple backups from different machines don't accidentally get mixed up.
3d) Create a sparse disk on your local Mac disk.
bigmac:/ kim$ hdiutil create -size SIZE -fs HFS+J -volname VOLNAME   HOSTNAME_MACaddr.sparsebundle

  • SIZE is something like 500g for 500 gigabytes.
  • VOLNAME is (apparently arbitrary) but something like "TM_Backup" or TM_HOSTNAME is ok.
  • HOSTNAME the hostname you found above
  • MACaddr the ethernet address you found above
Note: Adding the hdiutil "-shrinkonly" option to presumably prevent the image growing larger may be wise but I have not yet tried it.

bigmac:/ kim$ hdiutil create -size 500g -fs HFS+J -volname TM_Backup bigmac_001b63xxxxxx.sparsebundle

  • Do NOT try and run this command to create the disk image directly on your network drive. It won't work. I have not figured out why yet but probably something to so with hfs+ attributes that hdiutil expects to access and can't.
  • A sparsebundle is NOT the same as a .dmg or a .sparseimage. hdiutil will create all three based on the filename extension, but they are not interchangeable for Time Machine.
  • A sparse bundle with a size of 500g for example only takes up a few hundred meg locally, as data is put into it the size expands.
  • A sparsebundle is actually a directory that contains a number of data and control files

3e) Move the sparse image to the network share.
Quick Solution: mv bigmac_001b63xxxxxx.sparsebundle /Volumes/backup worked for me.
Longer Answer:
There are several ways to do this:
  1. mount the share and use "mv" (or possibly "ditto" ) from the command line eg mv bigmac_001b63xxxxxx.sparsebundle /Volumes/backup
  2. rsync from mac to server (eg rsync -avE blah.sparsebundle /Volumes/backup )
  3. even tar up the sparsebundle, mv and untar on the server.
There is a problem with mv and Samba however it doesn't seem to matter, at least not with Leopard 10.5.8.
The problem is that Samba shares don't really honour (or even understand) normal unix permissions.
So we have UNIX (mac) -> Windows Samaba protocol (strips permissions) -> Unix (File Server)
Thus permissions get lost when going via Samba. Whether or not this is important depends on the situation.
There are Samba options to help put add some sensible permissions, but as I understand it (possibly incorrectly) they provide a generic solution (all files become xxx, all dirs become yyy).
Thus if I do mv bigmac_001b63xxxxxx.sparsebundle /Volumes/backup the group and other permissions get set to 0 when looking at the files on the server. Because of this some people use rsync which transfers files and folders through an entirely different mechanism which preserves the necessary information.
As I said above however, Time Machine (Leopard 10.5.8) seems to take it in it's stride and work without a problem.

3f) Delete any original sparsebundle on the Mac.
If you copied (or rsync'd) the sparsebundle onto your network share you will still have a local copy. Delete it, it is just wasting space and you won't need it again.

4) Time Machine Configuration

4a) Mount the share if not already done
Note: Time Machine preferences only shows network shares it can currently see. So the backup share has to be mounted so you can select it in Time Machine.

4b) Select the share disk in Time Machine.
  • Open up Time Machine preferences and and Select "Change Disk".
  • The share should appear. Select it and close the dialogue.
Note: Time machine will try to mount the share itself under /Volumes, even though you already have it mounted. It will ask you for share username and password (just as Connect-To-Server does).
If it doesn't have any permission problems Time Machine will accept your selection and this will be reflected in the preferences.
(Time Machine stores the username and password in the System keychain for safety.) If there are problems refer to troubleshooting section.
4c) Unmount the share
Note: Make sure Time Machine is inactive first!!
I have included this step as the result of problems shortly after adding the share for the first time.

The problem may be triggered if the initial manual mount in step 4a) was done using the Finder, thus putting the share into /Volumes/backup (eg).
What happens is that Time Machine always does its own mount and the system names it, in this case /Volumes/backup-1 as /Volumes/backup is already taken. Although OS X transparently manages these mountpoint versions (-1,-2 etc) Time Machine can get confused and on subsequent backups complains not being able to access to the share. According to system.log Time Machine expects to mount share at backup-2, however the system doesn't do this - possibly just leaving backup-1 mounted. So Time Machine can't find backup-2 and gives up.

What fixed it for me was simply to unmount (sudo umount /Volumes/backup) when Time Machine was inactive (ie not in the process of backing up).
Check that all /Volumes/backup* mounts are now gone. (You need to do this as root because a normal user does not have the permissions to see any root mounted shares created by Time Machine.)
Use the mount command with no arguments to check all the mounts are gone.

Note: Trap for players - Even though the same share can be mounted twice on two different mountpoints (eg /Volumes/backup and /Volumes/backup-1 or /mnt/mybackup) when umount is run it unmounts ALL the identical shares because underneath the OS treats them as the same mount. So unmounting /mnt/mybackup whilst Time Machine is working on /Volumes/backup will abort Time Machine (something it actually seems to cope ok with - just takes up where it left offf next time).^
Here's an example from the logfile of TM/OS X finding an existing /Volumes/backup directory in use and creating a version "
-1" for timemachine to use. It does work sometimes.
Nov 18 16:44:27 bigmac /System/Library/CoreServices/backupd[2268]: Mounted network destination using URL: smb://kim@blackhole/backup
Nov 18 16:44:27 bigmac /System/Library/CoreServices/backupd[2268]: Backup destination mounted at path: /Volumes/backup-1

4d) Spotlight Admin
I'm not sure if this is required (and if/how it works transparently for "supported" Volumes - maybe Spotlight ignores certain Volume names...) but it is suggested that in System Preferences -> Spotlight -> Privacy you add TM_Backup to the list of Volumes not indexed (to avoid unnecessary CPU and Network activity and potentially wasted disk space). (To do this you must mount the sparse image itself so it is available for selection in Spotlight.) Unmount (eject) the sparse image when you're done.

Miscellaneous Details and Troubleshooting

  • Time Machine creates a file ".MACaddr" (eg .001b63xxxxxx) on the Share when it's first set up. This appears to contain a UUID but I'm not sure. If the file doesn't appear it suggests permission problems.
  • Time Machine creates log entries in /var/log/system.log under the name "/System/Library/CoreServices/backupd". This can be useful for troubleshooting problems. Either view the log from the command line or use Applications->Utilities->Console application to view it (Using console you can easily filter on the string "backupd")
  • Most problems seem to be a result of share permission problems. If you (as a user) cannot create a file on the share, Time Machine probably can't either. (I expect Time Machine runs as root though so it's worth checking that root can create files on the share too).
  • Make sure that the actual disk space available to Time Machine's sparse bundle image (on the backup server) will never fall below the sparse image maximum size (with a bit to spare), in the example above you need to guarantee 500G + a bit (not sure - say 500Meg) for rounding. Previously Mac sparse filing systems were rumoured to become corrupt if the actual space available was less than the specified maximum. This _may_ have been fixed but it is still wise to follow this advice. See also my note about hdiutil's -shrinkonly option.


NOTE: I need to review all these for accuracy of problem and solution

1 DIHLDiskImageAttach returned: 2 caused by pre-existant mounts confusing TM (basically it failed to mount the volume). Unmount all existing similarly named mounts (use mount command without arguments to check, then umount) and try again.
/var/log/system.log - TM Failure
Nov 19 18:25:49 bigmac /System/Library/CoreServices/backupd[94442]: Mounted network destination using URL: smb://kim@blackhole/backup
Nov 19 18:25:49 bigmac /System/Library/CoreServices/backupd[94442]: Backup destination mounted at path: /Volumes/backup-2
Nov 19 18:25:51 bigmac /System/Library/CoreServices/backupd[94442]: Failed to mount disk image /Volumes/backup-2/bigmac_001b63xxxxxx.sparsebundle (DIHLDiskImageAttach returned: 2)
Nov 19 18:25:51 bigmac /System/Library/CoreServices/backupd[94442]: Giving up after 3 retries.
Nov 19 18:25:56 bigmac /System/Library/CoreServices/backupd[94442]: Backup failed with error: 21
Nov 19 18:25:56 bigmac /System/Library/CoreServices/backupd[94442]: Ejected Time Machine network volume.

2 DIHLDiskImageAttach returned: 107 This error was caused by a misnamed sparsebundle - my computer name is not Mac (volume mounted ok)
/var/log/system.log - TM Misnamed bundle
Nov 18 16:39:08 bigmac /System/Library/CoreServices/backupd[2195]: Mounted network destination using URL: smb://kim@blackhole/backup
Nov 18 16:39:08 bigmac /System/Library/CoreServices/backupd[2195]: Backup destination mounted at path: /Volumes/backup
Nov 18 16:39:08 bigmac /System/Library/CoreServices/backupd[2195]: Failed to mount disk image /Volumes/backup/._Mac_001b63xxxxxx.sparsebundle (DIHLDiskImageAttach returned: 107)

3 Time Machine (and hdiutil) refuses to create a sparsebundle directly on the share. It starts and then fails. It's not a basic permissions issue.
Nov 18 16:44:22 bigmac /System/Library/CoreServices/backupd[2268]: Starting standard backup
Nov 18 16:44:27 bigmac /System/Library/CoreServices/backupd[2268]: Mounted network destination using URL: smb://kim@blackhole/backup
Nov 18 16:44:27 bigmac /System/Library/CoreServices/backupd[2268]: Backup destination mounted at path: /Volumes/backup
Nov 18 16:44:27 bigmac /System/Library/CoreServices/backupd[2268]: Creating disk image /Volumes/tank_timemachine-2/bigmac_001b63xxxxxx.sparsebundle
Nov 18 16:48:49 bigmac /System/Library/CoreServices/backupd[2268]: Error 45 creating backup disk image
Nov 18 16:48:49 bigmac /System/Library/CoreServices/backupd[2268]: Failed to create disk image 
Nov 18 16:48:54 bigmac /System/Library/CoreServices/backupd[2268]: Backup failed with error: 20
Nov 18 16:48:54 bigmac /System/Library/CoreServices/backupd[2268]: Ejected Time Machine network volume.

4 The following is _not_ and error as such. Just ignore it. Apple disk images can be set to eiher respect or ignore ownership permissions. If Ownership is enabled then permissions are preserved. Appropriate for normal backups/restores for a single machine. Not suitable for sharing data.
Nov 18 19:54:14 bigmac /System/Library/CoreServices/backupd[3319]: Ownership is disabled on the backup destination volume.  Enabling.


Just to show it can work...
/var/log/system.log - TM success
Nov 19 18:27:41 bigmac /System/Library/CoreServices/backupd[94442]: Backup requested by user
Nov 19 18:27:41 bigmac /System/Library/CoreServices/backupd[94442]: Starting standard backup
Nov 19 18:27:45 bigmac /System/Library/CoreServices/backupd[94442]: Mounted network destination using URL: smb://kim@blackhole/backup
Nov 19 18:27:45 bigmac /System/Library/CoreServices/backupd[94442]: Backup destination mounted at path: /Volumes/backup
Nov 19 18:27:48 bigmac /System/Library/CoreServices/backupd[94442]: Disk image /Volumes/backup/bigmac_001b63xxxxxx.sparsebundle mounted at: /Volumes/TM_Backup
Nov 19 18:27:48 bigmac /System/Library/CoreServices/backupd[94442]: Backing up to: /Volumes/TM_Backup/Backups.backupdb

  • + : A leading plus sign indicates that this word must be present in every object returned.
  • - : A leading minus sign indicates that this word must not be present in any row returned.
  • By default (when neither plus nor minus is specified) the word is optional, but the object that contain it will be rated higher.
  • < > : These two operators are used to change a word's contribution to the relevance value that is assigned to a row.
  • ( ) : Parentheses are used to group words into subexpressions.
  • ~ : A leading tilde acts as a negation operator, causing the word's contribution to the object relevance to be negative. It's useful for marking noise words. An object that contains such a word will be rated lower than others, but will not be excluded altogether, as it would be with the - operator.
  • * : An asterisk is the truncation operator. Unlike the other operators, it should be appended to the word, not prepended.
  • " : The phrase, that is enclosed in double quotes ", matches only objects that contain this phrase literally, as it was typed.


Related Sites