Monday, December 21, 2009

How To: Sync iPod Touch 2G using VirtualBox on a Linux Host

Well, the last couple of days have been spent setting up a virtual machine running Windows XP for my syncing needs (I usually use my PC for syncing my iPod, since it runs Windows 7, but when on the road, I will only have my netbook, and require some way to sync it). Therefore I always had the Windows XP partition on my netbook, however, I've not booted it since September, and before that I hadn't booted it for about 4 or 5 months. Since I use it so infrequently, I decided to get rid of the waste of space on my netbook and give that extra space to my media partition, my /home, my /, and possibly install a version of Ubuntu for my Full Circle Magazine articles (just to make sure my methods apply to it, etc.). At the writing of this post, the version of VirtualBox I am using is: 3.1.2-1 (virtualbox_bin PKGBUILD off the AUR). Now, according to some sources, the following step is unnecessary for this version of VirtualBox if you run HAL, but I did it and it's what I will probably continue to do. I will also skip the process of installing VirtualBox (Personal Use Binaries), simply because it varies to a large degree.

Preliminary step:
Add your user to the vboxusers group

sudo gpasswd -a $USER vboxusers

This will add your user to the vboxusers group, so that you can access virtualbox (most installations do not do this by default).

Step 1 (optional step):
Add the following to your /etc/fstab file:
none /proc/bus/usb usbfs auto,busgid=108,busmode=0775,devgid=108,devmode=0664 0 0
Since the layout cuts off the end of the above command, it ends with: "devgid=108,devmode=0664 0 0"
Ensure that you change the groupd ID (108) to whatever group ID is assigned to your vboxusers group. You can check this by issuing:
sudo grep vboxusers /etc/group
Once this is set up, you can force the usbfs to mount by issuing the following command:

sudo mount -a
For those of you who don't know, this will mount all filesystems listed in /etc/fstab.

Step 2:
Set up the guest machine. I installed Windows XP into a virtual machine using 384MB of RAM, 16 bit color, and basically the defaults for everything else (since it was running on a netbook). It's up to you what you allocate to the machine.

Once this is set up, install XP, and install iTunes. Before doing anything else, consider how you're going to store your music. I'm not a fan of copying an entire media library to a virtual machine just so I can continue updating it (and I only allocated 8GB to XP), so I decided to set up my iTunes folder as a VirtualBox shared folder. This is great for me, since I have a separate media partition (of about 70GB) with my Music, Movies, Pictures (and some backups) on an NTFS partition for access between the now dead XP install and any install of Linux I may have. Since this is the case, I created a virtualbox share for /media/Media/Music/iTunes/iTunes Music/ (your path will be different). To do this, install Guest Additions, and go to Devices --> Shared Folders. Set up the Folder and make sure you check the box next to "Make Permanent".
Now, in your XP host, right-click My Computer and choose "map network drive". The server is //vboxsvr/sharename (in my case, iTunes, but it will be whatever you chose previously). I mapped this drive to Z:, simply because I will never use that drive letter and so don't have to worry about any changes. Now on the guest machine, open iTunes, accept the license agreement, and head to the preferences (Edit --> Preferences), then open the "Advanced" tab and change the Music Folder to the Z: drive (or whatever letter you chose), and delete the original entry. This means that is should use the shared folder for any new music, podcasts, videos, etc. (I haven't tested that yet though). Once that's done, you need to add all the media to your iTunes.
This can be done by going to File --> Add Folder to Library, and choosing the iTunes Music folder (only if you have used the iTunes 9 way of organizing music, otherwise you may want to choose the parent directory to your podcasts, videos, etc.). Once the import is done (it can take a while), authorize the computer for any iTunes Store accounts you have, and plug your iPod in.

Step 3:
Syncing the iPod. Once you plug your iPod in, the Linux host will take control of it (which is fine). If you installed the guest additions and rebooted the guest OS, you should be able to go to Devices --> USB Devices --> iPod, and choose it. Give it a moment, and XP should inform you it found a new device (iPod), and begin installing the drivers for it. Once this happens, let it install and wait until it appears in your iTunes window. It will then warn you (if it's set to auto-sync), that some purchases are from another iTunes Library, whereupon you want to choose "transfer to PC" (or words to that effect), so that the purchases are synced to the iTunes folder. Once complete, your iPod should sync without a problem and you should be happier with all that free space.

If you want to update the music on iTunes, you should just import the CD/mp3s to the computer, and copy them to either the "automatically add to iTunes" folder, or add them to the correct folder in the Music sub-directory. iTunes may or may not automatically register/add the files (I haven't tested this yet either), but adding it manually is still less work than rebooting and doing it all there then copying it over to Linux. You can also import the CDs via iTunes in virtualbox and see if the CD will be ripped straight into the shared folder.

Hopefully this is interesting to anyone who was thinking of doing the same. I am quite happy (and surprised) to find that this solution works for me, even on my Samsung N110 netbook (1.6GHz intel atom, 2GB of RAM, 160GB hdd, intel 945GME), and frees up some space (about 50GB, since that's what I had left allocated to Windows). The best thing is I can create a backup of the hard disk, and save all my work, or use snapshots (or both). I know that you can probably sync the iPod to some degree in Linux natively, but I prefer having access to the podcasts I subscribe to (revision3 shows and engadget mostly) via iTunes even on the go.

For those who're curious about my partition layout on my netbook, it's as follows:
3GB Recovery Partition (Samsung)
68.36GB for Media
74.68GB Extended partition
  • 15.01GB /dev/sda5 (my arch root partition)
  • 24.44GB /dev/sda6(my arch /home)
  • 964.81MB /dev/sda7 (my swap partition, that I probably don't need).
  • 34.30GB of as-of-yet unallocated space (will probably become a 15GB Ubuntu /, and 14 GB Ubuntu /home, as to protect my theme settings and custom tweaks to Arch)

4 comments:

Anonymous said...

Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!

Lswest said...

Haha, thanks :) I've noticed that my ideas for blog posts also come easier to me than they used to, so I guess I'm just getting better at it :P Either way, thanks, and I'm glad you've enjoyed the posts.

Shane said...

I must say this is a time saver. I have a triboot sustem that will now only be a dual boot system. I use Mint and ZorinOS and have a shared drive with my Itunes Library. No more Windows Yeah. I had everything they way you have laid it out BUT the shared drive showing in Windows as a network drive. Thank you so much for taking the time to produce this.
Theball

Lswest said...

No problem :) Glad you found it useful! I figure if I'm going to take the time to figure it out myself, might as well stick it somewhere so I can do it again if need be, and so others can save some time!