O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  

Buy the book!
iPod and iTunes Hacks
By Hadley Stern
October 2004
More Info

Build a Cheap Linux Music Server
Build a Linux-based music server to store all your digital songs in a stable and affordable package.
[Discuss (0) | Link to this hack]

"Build a Cheap MacMP3/AACServer" covered how to create an awesome Mac-based digital music server. But what if you have a spare PC or a Mac that is too old to run OS X? For the old Mac, check out "Run iTunes on an Old Mac" . Otherwise, your best option is to look at creating a Linux music server for your iTunes music collection.

That's right, with an old machine you have lying around, and the best open source operating system out there, you too can easily build a jammin' music server. To make your jukebox complete, you can route your music to your stereo with AirPort Express and AirTunes.

Getting Linux to Talk to iTunes

There are many ways to go about setting up an iTunes remote library configuration. I suggest a universal method using Samba, which is best for novices. You could also set up Rendezvous on your music server, but in my opinion, the way iTunes 4 does Rendezvous library sharing is not ideal. By using the Samba file-sharing method, you keep the power to rate your songs as well as change the genre and other (ID3) song information.

Before we get started, there's one more bit to twiddle. By default, the "Copy files to iTunes Music folder when adding to library" option in iTunes is selected. Turn off this option before adding songs from your new hard drives to iTunes, as shown in .

Figure 1. Adding songs from your new hard drives to iTunes

During the Linux installation, make sure you allocate a hefty partition on your hard drive for the music files. For help with Debian GNU/Linux installation, see http://www.aboutdebian.com and, of course, Google.

Here are a few tips:

  • Once networking is working on your Linux installation, use Terminal in Mac OS X or download Putty for Windows so that you can SSH into your server from your other computer.

  • Some knowledge of Unix commands is helpful.

  • nano is a good basic text editor.

  • Use the df -h command and note the "Mounted on" area where your music should go. I recommend using/Music for the mount point.

Once you've completed this hack, you'll have an easily expandable place to keep your music. If you add another hard drive to your server, set it up using Google and the Debian manual. Then, repeat these steps to serve another share.

Server-Side File Sharing

If your main machine is a Mac, then on your Linux box you can use either Samba or NFS to share your files (Windows users do not have the NFS option). Though the NFS option is faster, Samba is easier to implement.

Option one: Samba.

Samba is your best bet to get off to a quick start. Its performance is not likely to be as fast as NFS's for large file copies between your computer and server, but it is good enough. Security is handled with user-based control, where you set up user accounts and passwords. It uses the same user information as Linux.

To install Samba, simply run sudo apt-get install samba. Now, you must configure the shares. You probably already created a user during the Linux installation, but you can add more users with the command /usr/sbin/adduser (if it's not installed, run apt-get install adduser) and set passwords with the passwd command.

To set up shares, Samba configuration is done in the /etc/samba/smb.conf file. To improve performance, I recommend adding this line after the [global] section:

read size = 32768

To set up your share, put the name of your share in brackets, followed by the share information:

comment = Josh's Music
writable = yes
path = /music
public = yes
valid users = josh, dan
admin users = josh

In my example, I have Unix accounts on my Linux system named josh and dan.

Now, it's time to create the connection to your Samba server. On your server, run /sbin/ifconfig to get its IP address.

If you're using a Mac, go to the Finder and select Go → Connect to Server. Then, enter smb:// followed by the IP address you just found. You can then log in and choose your music share. Add it as a favorite for quick access in the future.

If you're using a PC, go to the Start menu and select Run. Enter \\ip_address\music, replacing ip_address with your server's IP address.

Managing Your Library

If you are using a Mac, you can use either Samba or NFS as your server. For library management, use Doug Adams's iTunes Library Manager AppleScript (http://www.malcolmadams.com/itunes/itinfo/ituneslibrarymanager.shtml). It is shareware, free for up to two libraries—one for at home and one for on-the-go!

If you are using Windows, you must use Samba for your server. For library management, you might be in a tough spot, because I do not currently know of an available VBScript to manage iTunes libraries. One option is to use iTunes at home and use Winamp for your laptop's smaller collection of music when you're on the go.

Congratulations! Using off-the-shelf components and free software, you have set up a system to feed your music files to iTunes through file sharing over a network. Rock on!

Joshua Benjamin

O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.