Linux to the Rescue! Again! -or- Using GNUpod Fix a Corrupt iTunesDB File

aral sea drying up While trying to get some songs off of a 160GB iPod Classic (to a different computer from the one the iPod is registered with), I somehow managed to corrupt the iTunesDB file. This is a most important file, as it tells the iPod what songs are on it. Normally you can just plug the iPod into the computer it's registered with - when it synchs with iTunes, the iTunesDB file will be restored. In my case, that computer is 1500 miles away. After unsuccessfully trying a bunch of stuff on an OS X machine, I turned to Linux and GNUpod to save the day. Read on to see how it's done.

You can tell that your iTunesDB file is corrupt if your iPod tells you there are no songs available, yet you know for sure the songs exist on the device (eg the device reports that there's a bunch of space being used up or you take a look at the file structure and see that that are indeed MP3s on the device). There are likely other scenarios, but this is what happened in my case.

If your iPod says there's no music on there, you can check to see if there are music files by looking through the file structure using 'find' (on Linux, OS X). Mount your iPod and run:

find /path/to/ipod/iPod_Control/Music/ -type f -name *.mp3

Replace '/path/to/ipod/' with the mount path of your device, and if you know you've only got m4a files instead of mp3s on your iPod (or something like that) replace '*.mp3' accordingly. If 'find' returns any files, you know you've still go music on there.

Now you can use GNUpod to rebuild the database. GNUpod is easily obtainable for Linux and is likely compilable (or there may be some binary out there available) for OS X. If you're using Ubuntu you can do:

$ sudo apt-get install gnupod-tools

However, you will likely not get the latest version. I ran into some trouble using the version in the Ubuntu repositories and wound up compiling it. Download/compilation instructions can be found here.

Once you've got GNUpod set up, you can use GNUpod's 'addsong' with the 'restore' flag to rebuild the database:

$ gnupod_addsong.pl --restore -m /mnt/ipod

Be sure to change '/mnt/ipod' to the path of your iPod. Also note that if you installed GNUpod from the Ubuntu repository, you might not need to include the '.pl' extension.

What this command does is create an XML-based GNUpod database of the songs on your iPod. In order to complete the process, you need to tell GNUpod to turn it's own database into the iTunesDB. Do that with:

$ mktunes.pl -m /mnt/ipod

Now you can unmount your iPod and hopefully all your music will show up!

Post new comment

The content of this field is kept private and will not be shown publicly.