Devigner blog about development and design

How to Share Your iTunes Library With Multiple Macs and an NAS

I recently aquired a refurbed MacBook for my wife. She also owns a 30 gig iPod for her workouts. In addition, she’s a spin instructor and has a constant need to burn CD’s for her classes. I’ve always kept our music library of 70 gigs on a portable hard-drive connected via USB to my MacBook Pro; when required. Since my lovely wife is not as macnerdy as me, it’s been a drag on her to access the music library. If she needed to update the ipod she obviously used my mac.

Now I’ve updated our network to accommodate her needs. Here’s how we are sharing the music library and how I did the updates to the existing setup.

Essential Hardware

I picked up a 350 gig NAS which is formatted as fat32. I kept that as the format in case any shmuck (Jim) wants to access it with a PC.

Library Update

With the NAS connected to the wireless router, I hooked up the 120 gig external that housed the library for the last 3 years and copied everything over to the new drive.

I renamed iTunes Library and iTunes Music Library.xml located in ~/music/itunes to old and opened iTunes on my MBP. This gave me a clean slate to work with; a blank library.

Next, I changed iTunes preferences to point to the network drive for the storage location. There’s a few steps I’ll discuss later to help assure the drive is mounted all the time.

With the preferences changed, I chose “add to library” and pointed to the new drive’s library and walked away for about 2 hours for it to update the 11k songs (1200 cd’s) on the drive. It actually took almost a full day for iTunes to determine the gapless play and update the artwork library.

Problems when you sleep

One problem presented itself almost immediately and made me realize my wife would have bigger issues with her Macbook. It would just be a pain-in-the-ass for me — when I close my MBP (sleep), obviously the network drive connection dropped.

To get around this I setup a automator script that would mount the drive for me on startup. In automator, drag over “Get specified servers”. Click the plus to add a server, choosing the network drive. Drag over “connect to server” and then save it as an application to your desktop or somewhere safe. To automagically mount this when you startup the computer, open your system prefs and drag the application you just made to your login items (located in system/accounts). Now when I startup the mac, the drive is ready for use.

That still didn’t fix my sleep problems. So I downloaded Sleepwatcher and installed both scripts. With Textmate I created a file in my home directory named .wakeup and added in the following.


#Wake 10 seconds before connecting to the network drive
echo ‘sleep 10
logger -t sleepwatcher “connecting to the network drive”
open ~/Desktop/connect_to_server.app’ | /bin/sh&

Sleep is set to 10 to allow for the lag in the network on startup. With this script and sleepwatcher, I am now sure that my network drive is always mounted and ready for use. Cool thing is you can add anything you want done on wake to that script to save you some time.

Setting up the wife’s Mac

I fired up the wife’s Macbook and installed sleepwatcher for her computer, copied over the automator script I created earlier and the .wakeup script, and added the automator to her login items. Now I know she never has to mount the network drive.

I copied over the two files, iTunes Library and iTunes Music Library.xml located in ~/music/itunes, which were recreated when I rebuilt the music library earlier on my MBP to the wife’s macbook, letting them overwrite the files that were on her mac.

A Happy Wife

I fired up her iTunes and instantly saw our library on our network. She’s now able to access all music, burn cd’s and update her ipod from her mac as am I. So far, I’m not getting any conflicts with this setup at all.

A Probable Flaw in the Setup

The only foreseeable problem could be with purchasing new music from the iTunes store and/or adding new cd’s to the library from a rip. If I purchase a song or CD, I more than likely won’t be seen on the wifes computer, so what I plan on doing is symlinking the ~/music/itunes folders on both macs to one folder on the network drive. I haven’t tested it, but in theory, it should solve that issue. If not, there is software available that will sync the two libraries. I’ll update this post when I cross that bridge later this week.

I changed the wording in this narrative. The .wake script should be named .wakeup unless you edit your rc.wakeup file located in etc/ to reflect a different name. Also, very important, you must have execute permissions set for the .wakeup script to work properly.