The past week has been a rough one for all of my technology products. My MacBook Pro hard drive died, my tablet pc pen had a speck of crushed diamond or something equally hard that lead to a big gouge on the screen, half of my RAID mirror died on my development machine and some crappy software corrupted the iTunes database on my iPhone.
Word to the wise: as of January 1, 2009 there is no software available that can update the iTunes database on an iPhone or iPod Touch running firmware 2.x. Once the new hash for signing the database is reverse engineered this will be possible again, but until then be careful. I discovered this the hard way while trying to add some movies to my iPhone while my MBP was out of commission.
When you connect your iPhone after using one of the crappier utilities (quality apps tell you it's not possible) you'll be greeted with the following message:
iTunes cannot read the contents of the iPhone "XXX". Go to the Summary tab in iPhone preferences and click Restore to restore.
Restoring on a customized jailbroken iPhone is a bit of a pain; you need to reinstall all of your jailbroken apps, set your Winterboard theme, arrange all of your icons "just so", etc. It takes me about an hour to get everything just the way I like it, and I've got most of the process scripted out now.
Your iTunes database is stored in
/private/var/mobile/Media/iTunes_Control/iTunes and mine has the following files in it:
Extras.itdb IC-Info.sidb IC-Info.sidv PhotosFolderAlbums PhotosFolderName PhotosFolderPrefs Rentals.plist Ringtones.plist iPhotoAlbumPrefs iTunesApplicationIDs iTunesControl iTunesDB iTunesMovies iTunesPrefs
The suspect file was iTunesDB. My first thought was just to remove (rename) the iTunes directory and see what happened. Instead of an error I was prompted to configure a new iPhone or restore from backup. No go. When I refreshed the directory listing I saw that iTunes had re-created the iTunes directory.
I removed everything inside of the newly created
/private/var/mobile/Media/iTunes_Control/iTunes directory except iTunesDB and copied all of the files (except iTunesDB) from my backup directory,
/private/var/mobile/Media/iTunes_Control/iTunes-bad. Everything inside of the iTunes directory should be owned by user/group mobile/mobile and permissions set to 644.
chmod -R 644 /private/var/mobile/Media/iTunes_Control/iTunes chown -R mobile:mobile /private/var/mobile/Media/iTunes_Control/iTunes
I plugged my iPhone in and iTunes happily recoginzed it, sans music. Since it's a horrific music player (I love my touch wheel) I didn't care about this, my jailbreak configurationwas much more important.
You can download the virgin iTunesDB file here.