« Stackoverflow DevDays London | Main | Code formatting in C++ Part Two »

Using a networked drive for Time Machine backups (on a Mac)

You'll find similar information to this around the web, but I find it fiddly enough to piece together reliably, and I need it often enough, that I thought I'd blog about it. That way it at least gives me a single place to look. Maybe it will help others too. Much of the specifcs, especially the hdiutil command line and the ifconfig trick, I sourced from this thread in the ReadyNAS forums. Note that the advice is by no means specific to ReadyNAS drives (I have a Thecus NAS myself). Many thanks to btaroli in that thread for the insight.

Time Machine

Time Machine is Apple's easy-to-use backup system, baked into OS X (as of Leopard). Unfortunately it doesn't allow you to back-up to a networked drive out of the box. Enabling this ability is pretty easy. Early on there were some reliability issues - which were largely due to the fact that Time Machine created a disk image (more specifically, a sparse bundle) on the network drive, and this was prone to corruption if the network connection was disrupted during a backup. I don't know if all the issues here have been entirely resolved now, but it does seem more reliable. Apple's own Time Capsule, which has been specifically designed to work with Time Machine, uses this same method, so it is no longer an entirely unsupported technique.

Enabling Time Machine for network drives

So how do you enable backing up to network drives? Open a terminal window and paste the following in (then hit return, of course):
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
Mounted network drives will then show up in the list of destinations available for storing backups.

Getting a working disk image

Unfortunately this is not always enough. Often, after doing this, Time Machine will appear to start preparing a backup then fail with a cryptic error code. The error I have seen is:
Time Machine could not complete the backup.
The backup disk image "/Volumes/backups-1/Wall-E.sparsebundle" could not be created (error 45).
"Error 45"? What's that. If I try to create a sparse image myself in the same location I'm told, "the operation could not be completed". This is not much more helpful. If you google there are many references around to these errors - mostly in forums. Many of them are not terrible helpful, or require a lot of knowledge and/ or patience. I still don't really know what the problem is, although I suspect it's something to do with permissions and/ or attributes. Either way the solution generally seems to be to create the sparse image manually using a command called hdiutil. If you get this right then Time Machine will think it created it and just start using it. Simple eh? Well, it's not rocket science - but it does involve piecing a few things together. The name of the sparse bundle has to be something very specific which is made up from a few pieces of information unique to your set-up. I'll now take you through how to find those pieces of information.

Finding the Computer Name

We'll start with the easy one. The computer name. Specifically this is whatever the computer is named in the Sharing preferences. So open System Preferences, select "Sharing", and copy the name from the "Computer Name" section at the top.

Finding the MAC Address

This is the physical address of your network card (not your IP address, which is a logical address. Also the term "MAC" here is nothing to do with your Mac as a computer - it stands for Media Access Control address). Now you have to be careful here. Most macs these days have at least two network cards! You will probably have an ethernet port (for a network cable connection) as well as wifi. You may also have a USB based device, such as a mobile broadband device. Regardless of which one you use to connect to the network drive you'll be backing up to, the address we need is of the first network card (usually the ethernet port). If this seems a bit odd at first, consider the case where you usually connect over wifi, but to do an initial backup you connect by cable. If the backup name was dependant on the network connection used this wouldn't work. The address is only used to identify your computer. Anyway, it turns out there is an easy way to obtain this. Back in the terminal window, type the following:
ifconfig en0 | grep ether | awk '{print $2}' | sed 's/://g'
What's that doing? The short answer is "don't worry, it works". The slightly longer answer is that ifconfig dumps all the information it has about all it's ethernet ports. The first port is called en0, so the command ifconfig en0 dumps information about just that one. The pipe character, |, is the unix instruction for sending the output of one command to the input of the next. So we send the information from en0 to "grep ether", which filters out just the lines that have the word "ether" in them - which in this case happen to be where the MAC addresses are shown. To get that line into the form we need for our filename we pipe it to another command, awk, which just picks out the second part of the string, then finally to sed, which removes the colons. Phew. Like I said, it just works. Trust me.

Creating the sparsebundle

Now we have the information we need to create the name of the sparsebundle. Following is the instruction you need to issue to create it. Replace the <mac address> and <computer name> placeholders with the information we obtained above. You may need to change the size parameter (320g here) if you have a large drive to back up. The disk image doesn't take up that space to start with, but will grow up to the size you specify here, so use it to set an upper limit. Also you will be prompted to enter your admin password (sudo runs the command as SuperUser):
sudo hdiutil create -size 320g -type SPARSEBUNDLE -nospotlight -volname "Backup of <computer_name>" -fs "Case-sensitive Journaled HFS+" -verbose ~/Desktop/<computer_name>_<mac address>.sparsebundle
Note that this will create the sparsebundle on your desktop. Once there you can copy it to the desired location on your network drive (then delete from your desktop). This seems to be more reliable than creating it in place. Once you've done that you can start Time Machine and point it at the drive where the sparsebundle resides and it will find it and start using it. If this still fails, check that the name is exactly right and that you followed all the steps above carefully. Now sit back and relax, knowing that all your hard work is being backed up.

PrintView Printer Friendly Version

EmailEmail Article to Friend

References (1)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    Response: Time Machine OS X
    Time Machine OS X

Reader Comments (192)

Hi Phil, thanks for this solution. I had to copy Rahil's commands, and I got it to work to create a sparsebundle. Now I don't know what to do with it once I created it on my desktop. I have a MediaShare disk from Verbatim. It only allows me to connect over the air. The only other connection is esata, and I don't have that connection on my MacBook Pro. The MediaShare can be found in my shared folder. I am connected to it, but when I tried dragging the sparsebundle over to the MediaShare to copy it, an error message informed me that the MediaShare cannot be modified. How can I copy the sparsebundle over to the MediaShare?


February 8, 2011 | Unregistered CommenterScott Vermillion

Excellent..... Many thanks!

February 18, 2011 | Unregistered CommenterMBS

@Scott. Unfortunately I'm not familiar with MediaShare so can't offer any help. Maybe someone else will.

February 18, 2011 | Unregistered CommenterPhil Nash

Hey Phil...

I recently picked up the Seagate GoFlex Home and I followed all of your steps listed out above, however, I have been getting error messages that say backup could not be completed b/c the "stashbundle is in use". Any ideas as to why this could be happening?

The only thing I can think of is that maybe I need to kill the Seagate software that runs in my browser to add/remove other files on the drive...

February 23, 2011 | Unregistered CommenterZezo One

Please accept my thanks for this. You not only fixed my connection to the Time Capsule, but gave me a good way to use a normal network drive as a backup when the Time Capsule Drive fails. Your expertise definitely means you are an OSX guru, so thanks for taking the time to help up less fortunate.

March 1, 2011 | Unregistered CommenterPaul

Got this working with a HD connected to my network through a free agent dockstar (pogoplug). Backing up now!

March 10, 2011 | Unregistered CommenterAdam

Thanks for a great article.
I have been using the backup for the 9 months since I got my new Macbook Pro.
On Saturday night, without warning, my hard drive crashed. I spent Sunday trying to fix it and gradually came to the conclusion that I had to rely on my fedora based backup.
When apple had replaced the HD I simply installed a temp account, copied the backup image from the server to a usb drive and then used Migration Assistant to reinstall Accounts, Apps, Docs etc from the usb.
Then I simply updated the software from inside my proper account and all is well with the world.
Thanks Again,

March 18, 2011 | Unregistered CommenterGrateful

this post works a dream - my problem was with a Buffalo which this sorted out - being very stupid did not appreciate at first I had to remove the "<" and ">" when adding my mac name and mac address when copying the command into terminal

next stop ..how to backup a mac / time machine onto a windows home server which is a very (very) easy (and cheap) way to back up multiple windows machines on a home network

March 21, 2011 | Unregistered CommenterNick Roads

Great info - I tried this last year based on similar info but could not make it work. Now I am backing up in the background over wireless 802.11n to a USB drive connected into my router.

I did have a problem with the drive disappearing every time I restarted my Mac. Solved by adding these drives in System Preferences/Profiles/Login Items. Sure enough they pop up in focus in Finder, but I cannot suppress the Finder window at login. Still, small price to pay.

Thanks - QJ

March 21, 2011 | Unregistered CommenterQJ

Hi Phil,

I was so happy to find your instruction on how to set up timemachine connected to NAS (mine is LG N2B1 / N2R1). I'm a new user to Mac and need some help on this one.

I've followed your instructions and have executed the following command:

sudo hdiutil create -size 750g -type SPARSEBUNDLE -nospotlight -volname "Backup of Trine Rosenkrantz Jørgensen’s iMac" -fs "Case-sensitive Journaled HFS+" -verbose "/Desktop/Trine Rosenkrantz Jørgensen’s iMac_d4:9a:20:d0:f2:53.sparsebundle"

actually in several versions (mac adress with and without <:>)

and I get the following result

DIHLDiskImageCreate() returned 2
hdiutil: create: returning 2
hdiutil: create failed - No such file or directory

What's wrong? Hope you are able to help me here.

Thanks in advance/Bo

March 23, 2011 | Unregistered CommenterBo J

Hi Phil!

Seems to be a lot of success on this blog but I'm doing something wrong?

Keep getting this on my terminal:

Last login: Thu Mar 24 16:05:26 on ttys000
Unknown-00-1e-c2-19-0b-09:~ philiphouston$ sudo hdiutil create -size 320g -type SPARSEBUNDLE -nospotlight -volname "Backup of philiphoustonsimac(9)" -fs "Case-sensitive Journaled HFS+" -verbose ~/Desktop/philiphoustonsimac(9)_00:1e:c2:19:0b:09.sparsebundle
-bash: syntax error near unexpected token `('
Unknown-00-1e-c2-19-0b-09:~ philiphouston$
Unknown-00-1e-c2-19-0b-09:~ philiphouston$

I hope you can help?

Trying to connect a 2T buffalo to my imac.


March 24, 2011 | Unregistered CommenterPhilip Houston

Hi again Phil,
I forgot to mention that I couldn't mount the drive

Enabling Time Machine for network drives
So how do you enable backing up to network drives? Open a terminal window and paste the following in (then hit return, of course):
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
Mounted network drives will then show up in the list of destinations available for storing backups

Comes up with this

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
Unknown-00-1e-c2-19-0b-09:~ philiphouston$


This is all alien to me.


March 24, 2011 | Unregistered CommenterPhilip Houston

Brilliant. That has saved me hours of stuffing around.

March 27, 2011 | Unregistered CommenterLiam


Try putting the path at the end in quotes

March 29, 2011 | Registered CommenterPhil Nash

Hello, thanks ! I did as instructed by you. I could create the image easily and copy it on my network drive (Iomega) ; I could see the temp file being created (after the 120 sec delay !) but... too sad... again this error 45! No need to say that I had also renamed the computer without blanks...

I am desperate : I have spent more than 5 hours on this issue and it seems hopeless... Would you have a little clue how to get trough this ?



March 30, 2011 | Unregistered CommenterSergio-Paris

Additional question ! The colons in the classical MAC address turn into slashes... So I fear that this is creating trouble. I want to relaunch the creation of the image then I get "only one image can be created at a time"... Although I have put the previous one to the bin...
If you have any idea how to overide this...

March 30, 2011 | Unregistered CommenterSergio-Paris

I have redone the image via Disk Utilitaries and now when I click on Time machine, I have a strange reaction: no count down with seconds but stars in a balck universe with a kind of white hole in perspective... Can someone explain that to me? Please...
On the Iomega drive the file < *.sparsebundle > seems to have been updated... Would it mean that it works?

March 30, 2011 | Unregistered CommenterSergio-Paris

Latest News!
I had trouble to relaunch the automated process of Time Machine (dis-activated). But when I succeeded (via Preferences), this time, it worked!
So using the "Disk utilities", "Create new image", select the right options...(mine were: 500 M/Case-sensitive Journaled HFS/no encryption/single partition/SparceBundle) with the naming <ComputerName>_<MACaddress> then double-finger-click and "post in Finder", then drag'drop the file into the network backup directory.
Still I have a question regarding the password requested by the backup directory... is it saved in the Macbook keyring ?
Hope this can help someone in my case.
Take courage!

March 30, 2011 | Unregistered CommenterSergio-Paris



My MacBook Air made an unsuccessful attempt to create the sparsebundle on its on on our WD MBWE. The crisp and clear instructions you've provided had TM in business in short order.

April 16, 2011 | Unregistered CommenterAndy

Thank you for this post. I have been struggling for weeks; your post was clear and easy to follow. Thank you.

May 4, 2011 | Unregistered CommenterClaire

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>