Sunday, January 18, 2009

Setup iTunes on Linux for syncing with AppleTV


Purpose
I have an AppleTV that has been modified to run boxee. However, I don't like how boxee handles music. I like how the native unmodified TV software syncs with iTunes and handles music.

The Problem
I have a very large music library (110GB, >20,000 songs). I have 2 Apple laptops that are not always connected to the network so I can't use those to sync with ATV, not to mention the hard drives on the laptops aren't large enough. I have a central server running Ubuntu 8.10 that works as my media server. Ideally I would like to have the AppleTV sync with my server. However, there is not linux version of iTunes and none of the other great linux audio software can be set up to sync with iTunes.
Failures
I first t
ried installing iTunes under Wine. It installed fine but bonjour could not. Apple uses Bonjour to announce the presence of all of their devices on the network. Without it none of the devices could find the shared library and the version of iTunes running on Ubuntu under wine could not see the AppleTV.

The Solution
Requirements: VirtualBox Software, Copy of Windows, iTunes 7 (I don't know if it will work with 8)
1. Download, install and setup the appropriate version of Virtual Box for your linux distribution.
2. Install w
indows on virtual box, I used Windows XP sp2. Make sure you install the windows guest additions provided with VBox.
3. KEY STEP. Networking must be set up as "Host Interface Networking".
⁃ This allows the iTunes shared library to be seen from and by all the machines on the local network
4. Set up Host Interface Networking
⁃ “With Host Interface Networking, VirtualBox creates a new networking interface in software on the host computer. This new software interface will then exist in parallel to your regular interfaces (e.g., on a Linux host vbox0 will exist alongside eth0). When a guest is using such a new software interface, it looks to the host system as though the guest were physically connected to the interface using a network cable: the host can send data to th
e guest through that interface and receive data from it. This means that you can set up routing or bridging between the guest and the rest of your network.” from the Vbox User Manual
⁃ In order for HIN to work you must setup a Network Bridge for eth0
⁃ For Ubuntu I did this by: (Don't do remotely since your network has to be restarted)
⁃ Installing bridge utilities package
sudo apt-get install bridge-utils
⁃ Add an entry to the file /etc/network/interfaces to describe the bridge (br0)
sudo gedit /etc/network/interfaces
⁃ Paste
auto br0 iface br0 inet dhcp bridge_ports eth0
⁃ I left mine as DHCP and it seems to be working fine. However, you may want to assign a static IP address to the bridge. (Google is your friend)
⁃ Restart networking
sudo /etc/init.d/networking restart
⁃ Now every time you start your system a network bridge will be created
⁃ Now create a permanent host interface named vbox0
sudo VBoxAddIF vbox0 br0
⁃ Replace with the name of the user who is supposed to be able to use the new interface.
⁃ Now tell VirtualBox to use the interface
⁃ Select the Windows virtual machine you created earlier.
⁃ Configure one of its network adapters to use Host Interface Networking (using “Settings”, “Network”, “Attached to”) and enter vbox0 into the “Interface name” field.
5. If your windows system is firewalled, then ports 3689 and 5353 must be open for itunes to work.
6. Install iTunes, add your music library folder (see vbox instructions for sharing folders) and enable music sharing in iTunes.
7. Voila this virtual machine is now serving up your virtual library. Now go to the ATV and enable syncing with this iTunes library. A 4 or 5 digit code will be displayed on the ATV this must be entered on iTunes after clicking on the ATV in the left hand pane.
8. Now should be all synced up.

No comments: