Recovering a corrupt iTunes DB on an iPhone

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.

 

Tags: , , , ,

35 Responses to “Recovering a corrupt iTunes DB on an iPhone”

  1. Fadi Says:

    I totally commiserate. I just had the same experience (like tonight!). ImTOO just screwed up my iPodDB when I used it to delete an album. Unfortunately your warning came too late as I am reading this article after the fact. I have spent a quadzillion hours hacking and tweaking my iPod and I use it as my only mp3 player (I have a different opinion about the click wheel), so you can imaging my horror and heart attack when I got the iTunes message and saw that my Music did not display in the player.

    ===================================
    My final solution (after hours of messing around):
    ====================================
    Slight variant on what you had done/ Keep iTunes closed while you do this. I have tool called i-FunBox (it's free at http://i-funbox.com/ ), let's me see, alter and browse the iPod touch as if I was in explorer. I used it to rename iTunes_control to iTunes_control2 (or BAD). I did not make any new iTunes_control directories. Opened iTunes up, when it I was prompted to configure a new iPhone or restore from backup, I chose configure new iPod. It simply rebuilt my iTunesDB and resynced the music that is in my PC's iTunes. It did not delete my Applicaton or format my disk as it would have had I selected the restore to factory settings… If you only have your music on your iPod (lost your original Mac or PC's original iTunes), you can can use i-FunBox to dump iTunes_control2 onto your HD, dragg the Music folder into Windows iTunes and let it rebuild a new database.

  2. Adam Says:

    I also followed the final solution from Fadi's comment on my 3G iphone and it worked like a charm. Thank you to the original blogger and commenter for publishing your recovery methods!

    Adam

  3. M2 Says:

    The method I've been using is simply browsing my ipod using WinSCP, and deleting the entire Itunes_Control folder. When you start up itunes again it asks you to restore, and all the apps and jb stuff is kept. Now, the question I have is, has anyone found a way to simply un-corrupt or rebuild the database somehow, so I don't have to re-upload all my music every time? The reason I am asking is because my iPod Touch gets corrupted an average of once a month…

  4. totolita Says:

    You are my personal hero!!!!!!!!! Thank you very much for this, I had your exact problem and it works like a charm now!!!!!!!

  5. Stef Says:

    Thank you so much!! ImTOO completely messed up the iTunes database on my iPhone… I was afraid I would have to restore it again. Instead I just renamed the iTunesDB file and it worked again! iTunes now recognizes my iPhone as before :-)

  6. kk Says:

    really great solution. hats off to you dude.

  7. Guy Says:

    Hi,

    I have another weird problem. i have a 3G iphone, which worked fine until its database got corrupted. i did exactly what you mentioned here and chose setup a new iphone (instead of restore which i don't want to do) and the problem was almost fixed. By almost i mean that Itunes recognize my iphone but does not let me transfer any mp3s to it claiming mp3 is not supported format by my iphone. on top of that my applications and video folders under my iphone device (when you click on the triangle left of the device name) are gone and i can't sync neither applications nor video. so now I am stuck with the inability to sync anything. please help

  8. gerbaux Says:

    thanks a lot for your solutions!!!! now i can back up my contacts before restore!!!

  9. Aarif Says:

    i have same issue as mentioned by GUY, I too cant sync my iphone with itunes.
    i have done these steps earlier but i dont why its not working now
    only difference is that i have iphone 2g
    with firmware 2.2

    Any sugestions from your end would be helpfull

    Thanks

  10. wilbert Says:

    Help is appreciated.

    Imtoo ipod transfer messed up my database. transfered some videos but nothing shows up. yet it consumes the available space.

    Thanks in advance
    my email add is schwanella_chong@yahoo.com

  11. Raj Swami Says:

    I agree with what Fadi Says.

    He became my personal hero too.. I am from India and have jail borken iphone and I got same error. I eventually come to this blog and … yes Yes YES YES YES. I got the solution.

    Its great. Thanks to you all and also the i-FunBox team.

    Thanks and regards,
    Raj Swami.

  12. Raj Swami Says:

    After rename the itune database , connect to itunes and create a new database. After that you can delete the older database. Else the space with old corrupted database will not be available for use.

    This works.
    Thanks in Advance,
    Raj Swami.

  13. CR Says:

    I found this and it solved my problem. However, I just SSH'd into my iPhone and deleted the iTunesDB file all together. It seemed to do the trick, but this post led me in the right direction.

  14. fulldeto Says:

    Hey man, you saved me the neck…

    Thanks a lot.

  15. Super_Dave Says:

    Writing this from my fixed iPhone. Playing music and loving it thanks to this thread. I used the trial version of ifile which I'm now inclined to purchase. My db was corrupted by sharepod deleting an album. I used ifile to locate the directory. In the dolder that says itdb Inside that folder is a iTunes db backup. I copied the backup to the main folder and itdb. Voilà. Music playing.

  16. Waylander Says:

    I attempted the "Recovery of a corrupt Itunes DB on Iphone" posted by Corey Gilmore, I did eventually get my apps, and contacts back, but no iTunes music, whilst apps and other stuff syncs, music will not, iTunes simply hangs.

    I think I might have made some mistakes with permissions, can anyone tell me what the default permissions are for the "Music" folder and files in it, and for the "tmp" folder.

    Please help !!!

  17. Corey Says:

    /var/mobile/Media/iTunes_Control/Music is owned by mobile:mobile and set to 700.
    It's filled with F## directories that are mobile:mobile and set to 755.
    The F## directories contain files that are mobile:mobile/644.

    The process I outlined here isn't meant to help you recover your music, it's meant to help you avoid having to restore your iPhone from a backup because the iTunes DB is corrupt. Restore using the blank iTunes DB, and then sync your music/movies back from iTunes.

  18. Slono Says:

    Hi,

    I had the following problem which is not exactly the same as the described above, but it is close enough: I updated from 8.x to 9.0.x today and all my music was lost, some 2 GB, all gone to "Others"

    I did solve it as follows:
    - delete all music, podcast, downloads, videos, recordings from ipod that is still recognisable under the /var/mobile/Media and /var/mobile/Media/iTunes_Control directories, if any (I used openssh)
    - move iTunes_control to iTunes_control-bad or similar (move NOT copy) — to make a backup, just in case
    - delete all contents inside F00–F13 (in my case just 13 folders) in the Music folder inside iTunes control. This was the "Others" content
    - sync

    Voilà! "Others" should disappear

    Cheers,
    Slono

  19. Matt Says:

    Running 3.1 on an iPhone 3G, I'm abroad (away from my Mac with all of my music) and downloading new podcast episodes on an unreliable WiFi point corrupted my music database so it says no music and none of my audio books show up. I've never had this happen in all the years I've had an iPhone (jailbroken or not). Is there anyway to rebuild the database on the phone?? I can't survive 10 hour bus rides in Central America with my audiobooks. At least the podcasts still show up. I've read two other identical incidents googling around but no one has a solution yet. I have terminal access to the phone and am willing to try about anything at this point.
    Please help! I need my music back. Thanks,
    Matt

  20. Stuart Says:

    Hi. This is my situation due to my own stupidity and tiredness

    Ipod touch 32g 2gen
    Ubuntu Netbook remix 9.10
    No itunes program. Travelling.

    This is the bad bit. i don't have any backups. Unforgiveable. Anyway

    No itunesDB in var/mobile/Media/itunes_control/itunes on ipod
    No music folders in /music on ipod

    I connect via fuse to ipod and it is seen on /media/ipod
    Access is denied when i try to enter folder.

    i tried your above method and now i cannot access itunes on the ipod. It does not load.

    I will give more details if requested.

    Where do i go from here?

    Stuart

  21. Harold B Says:

    Found and easier way! download and install, ifunbox at http://i-funbox.com. then find the file “iTunesDB” and delete it, after that open iTunes in Windows/Mac connect the device and WALA! you are back to syncing.

  22. Regis Says:

    Another way : just download the free version of MediaMonkey. It will find again your music and then will repair automatically the database. After that, the sync with itunes is possible again. Not an easier method ! Found this method on the web. But can't remember where. Thanks anyway to the author!

  23. janna Says:

    Can I delete the iTunes_control file?? Because the music I previously had will not show up on my ipod or in itunes but it's taking up space on my phone.

  24. Paul Canavan Says:

    Just wanted to say many thanks. Been struggling with a corrupt DB for a few days now. I only have a linux box and it's been a pain trying to sync anything. Just got some music transferred over this minute.

  25. Backbeat Says:

    I am having the same problem,in my case I was downloading some podcast and after that I tried to
    Open iPod but it hanged so I press home button and again tried to open iPod but this time it open properly but says there are no music files but when I checked the storage size from setting ' about' I could figure out that the songs are still there so I used iFiles to browse thru the iPhone file and saw that in iTunes_control folder inside which iTunes folder is present but inside it ituneDB and itunescontrol are 0 KB in size

  26. Backbeat Says:

    Cont…..
    I installed the virgin iTunesDB but still my itunescontrol DB is missing so it is not yet fixed and my bad luck is that my computer used for regular syncing is not working so now I m left with no music . If anyone can upload the itunescontrol file then I can try out my luck :)

  27. justin Says:

    this worked great!!! A quick and easy fix, all i had to do is reconfigure my ipod with itunes after i copied the itunesDB file. Thanks alot.

  28. Bhavik Says:

    Thanx a lot guys!

    My pc shut down while copytransmanager was transferring data and that corrupted the library and required a restore.
    Did the process as Fadi said. Worked like a charm!

  29. alex mediapub Says:

    i have the same problem…after getting this information i editted the code of itunes,then it is now working properly.i think meda monkey will not help you to fix this problem…..

  30. Jake Says:

    Been trying to do this for ages! Thanks for the tutorial.

    Jake

    Buy iPhone Without Contract

  31. Aiman Says:

    I add x at the end of these two files (renamed them) iTunesDB & iTunesDB

    in

    /private/var/mobile/Media/iTunes_Control/iTunes

    them start itunes and i can see my ipod touch 3g

  32. Lucy Says:

    ok soo i need help.. i deleted the itunesdb file and the itunescbd file. i also delete the entire music file in itunes_content by mistake.. and yes i can now sync but i cannot sync any music. my iphone still lists all my music but there is absolutely no content so the ipod just skips the track..
    is it possible to get back these files?
    i downloaded the "virgin itunesdb" but i have no clue what to do with it, with my situation..
    please help!
    thanks

  33. Alex Says:

    I deleted the whole iTunes_Control folder and I'm experimenting what might happen.

  34. Danny Says:

    Thanks a lot ! After trying all the solutions on the internet, this was the one that finally helped me. Thanks once again !

  35. Great Says:

    GREAT!!! Thanx a lot!!! <3 <3 <3

Leave a Reply


© 2007-2013, Corey Gilmore | Posts RSS Feed | Comments RSS Feed | Contact

 

The views expressed on these pages are mine alone and not those of any past or present employer. All information presented on this site was obtained lawfully and not through disclosure under the terms of an NDA.