iPods on Linux
#36 Henry, Monday, 18 January 2010 9:32 PM (Category: Gadgets)
(Tags: ipod slackware gtkpod)

The way I organise music appears to be different to the way the rest of the world does it. My Linux desktops at home and work have an external 500 gig drive attached. This contains the mp3s. It's almost full. I keep the one at work and the one at home in sync, using rsync. This is good because it gives me a backup, just in case, and I have had to use the backup facility several times.

I play the music on my Linux desktops. I used to use Amarok, now I use aTunes.

I also have a Mac Mini with an external 500 gig hard drive, and I keep a third copy of the mp3s on this and I keep it in sync with my desktop using rsync.

When I get a new cd, I rip it on the Linux desktop, transfer it to the external hard disk, then rsync it to the one at work and the one on the Mac Mini. Amarok and aTunes have a very easy way to update. They know what they have, and they can quickly load the new music. It takes a couple of minutes for them to find and load the new cds. iTunes doesn't do this. It expects to be the master repository of the music and everything hangs off it. For me, it's just a client. So my way of doing music is not suited to the iTunes way. And that's why the iTunes library is about a year behind. It's just too much of a pain to update it. I tried dragging the entire directory structure and dropping it on iTunes, hoping it would ignore files it already had, but no, I ended up with duplicates of most things, and singles of the new files. I had to blow away the whole iTunes library and then drag and drop the directory again. Then wait a day for it all to load. So the files all sit there, available to iTunes, but there is no easy way to tell iTunes to just load the new and changed files. So I tend not to do it because there's no easy way.

I use iTunes on the Mac Mini for two things: putting music on my iPods, and connecting to the stereo via the Airport Express and Apple Remote on my iPod Touch.

Today, I thought I may as well remove one of those uses. I did some research and discovered that it might be possible to load the music from my Linux desktop directly to my iPods. I experimented, and went with gtkpod.

First, I downloaded and installed libgnomecanvas as it was the main dependency that gtkpod needed. Then I downloaded and installed gtkpod. Went easily and well. Then I had to make all the connections. I have a 30 gig Video iPod, and it's a Mac iPod. Some are formatted for Windows and are vfat, and some are formatted for Mac and are in hfsplus format. Mine was the hard one.

I looked at the instructions for gtkpod at http://www.gtkpod.org/README. It would like the iPod mounted at /mnt/ipod. So as root, I created /mnt/ipod.

Then I connected it to my Linux box and used dmesg to see what came out. It's recognised as /dev/sdc with three partitions.

 sdc: [mac] sdc1 sdc2 sdc3
sd 15:0:0:0: [sdc] 14651280 2048-byte logical blocks: (30.0 GB/27.9 GiB)
sd 15:0:0:0: [sdc] Assuming drive cache: write through
sd 15:0:0:0: [sdc] Attached SCSI removable disk

I experimented a bit with mount, manually trying to mount the different partitions.

mount /dev/sdc1 -t hfsplus /mnt/ipod

and found that /dev/sdc3 was the one I wanted. After mounting, I did an ls of it and it showed this directory structure:

drwxr-xr-x  1 root   root       17 2010-01-18 13:49 ./
drwxr-xr-x 15 root   root     4096 2010-01-18 21:20 ../
dr-xr-xr-t  1 root   root        2 1903-12-31 19:00 .HFS+ Private Directory Data
drwxr-xr-x  1 nobody nogroup     3 2007-11-26 22:24 .Spotlight-V100/
drwxr-xr-x  1 nobody nogroup     2 2010-01-18 14:12 .Trashes/
-rw-r--r--  1 nobody nogroup 39325 2007-04-18 19:24 .VolumeIcon.icns
-rw-r--r--  1 root   root     4096 2007-04-18 19:23 ._.Trashes
-rw-r--r--  1 root   root       82 2007-04-18 19:23 ._iPod_Control
drwx------  1 nobody nogroup     7 2010-01-18 13:54 .fseventsd/
drwxr-xr-x  1 root   root        2 2009-08-25 15:59 Calendars/
drwxr-xr-x  1 root   root        4 2009-08-25 15:59 Contacts/
-rw-r--r--  1 nobody nogroup  1024 2007-07-22 20:05 Desktop DB
-rw-r--r--  1 nobody nogroup     2 2007-07-22 18:46 Desktop DF
drwxr-xr-x  1 root   root        3 2000-01-01 03:22 Notes/
drwxrwxrwx  1 nobody nogroup     3 2007-05-23 01:01 Photos/
drwxr-xr-x  1 nobody nogroup     9 2008-05-29 16:54 iPod_Control/

That's the one I want.

So I edited /etc/fstab to have an entry so I could easily mount the iPod.

/dev/sdc3       /mnt/ipod        hfsplus     noauto,rw,user,exec     0   0

Then I started gtkpod. It worked. It found my iPod and would let me access the files on it. My first test was to load some new music on to it. Failure. It was a read-only file system and I couldn't write to it. But wait, I set /etc/fstab so that it was read-write. Why is it read-only?

I used dmesg to see if anything was happening behind the scenes and aha, there was:

hfs: write access to a journaled filesystem is not supported, use the force
option at your own risk, mounting read-only.

I did some research and found this informative discussion on Ubuntu forums and that showed me what to do. My iPod was using journalling, and Linux was not going to accept that. I had to turn journalling off. I had to attach the iPod to a Mac, get the command line and type this to turn journalling off:

diskutil disableJournal /Volumes/(name of ipod)

I did it, it appeared to work. Then I followed up by adding some music from the Mac to the iPod through iTunes. That worked too. I then took the iPod back to Linux and mounted it again. It loaded read-write. Success. I started gtkpod again and this time I could add new music to the iPod via gtkpod on Linux. I regarded that as a major win. Now I can load my music onto my iPod from the most up-to-date music library I have.

I have three iPods and one thing I had to do with gtkpod was work out which type of iPod they were and then which model they were. I could get model numbers from the Settings on the iPod (except the iPod Shuffle), and then I used the Apple support page to work out which type of iPod they are. Turns out I have a 1st generation Nano (2005), a second generation Shuffle (2006), and a 30 gig fifth generation Video iPod (2005). All old, but still useful.

That leaves playing music from iTunes to the Airport Express to my stereo. I use this less than 10 times a year. Last time I used it was with a playlist I set up for the New Years Eve dinner party. It worked really well. I'll keep reading. Maybe there is some way to make iTunes pull the music from my Linux music library.