title: Daemonic iPod category: tech content: |
Since the disk controller on my Macintosh decided to die (it would have been four years old in September) I wanted to figure out a way to use my iPod without Mac OS X, without Windows. I didn't have the money for a new Mac -- well, not the kind I wanted, anyway, and El Steve's announcement about Intel chips didn't exactly compel me either -- so I instead built a new workstation from parts. The highlight being the Athlon 64 X2 dual-core processor. I run FreeBSD on it most of the time, even if it does have a small Windows partition for silly BIOS/firmware updates and the occasional shot of MMORPG crack.
(Warning for syndicated readers: this is in the "tech" category, so it could get geeky past this point. Proceed with caution. Actual proper site visitors should consider the "tech" tag as enough of a warning in itself.)
And having rescued as much data as possible from the disks that nearly died at the hands of the old G4, I set out to solve the problem of how to make the iPod work nicely with FreeBSD 5.4 on hardware that was neither Intel nor Apple.
USB turned out to be a non-starter. Sure, it was recognized as a mass storage device, but never as something vaguely disk-like. (By contrast, generic no-name USB compact flash reader is handled with much grace.) Good thing I had already bought the Firewire cable for the iPod, since that was the only way I could get decent transfer rates from the old Mac.
And then there was the minor matter of FreeBSD not grokking Apple's HFS+ filesystem natively. I could either get a new, experimental kernel module (which I used to rescue data off other disks) or just spank the iPod into "Windows" (FAT) format. The latter proved to be the easier choice, since just about every operating system knows how to deal with FAT. (Heck, even a FAT disk plugged into Mac OS X on PowerPC hardware shows up automatically!)
Then there was software. For now, I have settled on GNUpod because
it is a collection of tools I can rearrange, modify, and generally
bend to my will as I see fit. Took gnupod_addsong.pl
and turned into gnupod_linksong.pl which hard-links
instead of copies files, so I could create a "Platonic Ideal
iPod" without consuming more disk space, and without troubling
the real iPod with strange I/O. Then
rsync to transfer it over
to the actual iPod.
Unfortunately there was the detail of the iPod and FreeBSD not agreeing what proper SCSI-over-Firewire transactions should look like. Usually the iPod won; it got a bit warm to the touch, started making funny noises, and generally became unresponsive to further attempts to communicate with it. Good thing it has magic keystrokes to reset it. The act of resetting it invalidated the virtual SCSI disk, but didn't unmount the filesystem. Attempts at unmounting nicely ended with EAGAIN ("resource temporarily unavailable"); forceful unmounting sent the machine off into deep kernel la-la land, also known as "wedged." Also a good thing I consider the workstation a freely rebootable machine.
I finally discovered a combination of switches to
rsync and filesystem mount options that allowed
me to fully sync the Platonic Ideal iPod to the actual device.
The approach was to minimize the amount of useless data sent
over the link -- it was slow enough as it was -- which meant
removing useless metadata, like file ownership and modification
time, and performing the I/O as safely as possible, i.e.
synchronously.
The commands are basically:
And I present them here for my benefit as much as yours. If I weren't such a dork about trying to figure this out myself, I would have done more research on the INTARWEEB and probably had an answer a couple of weeks ago. But at least I feel victorious over silly tech issues, even if I re-invented a small wheel or two along the way.
There is of course a tiny bit of user interface sugar around it -- I am still pretty much a command-line geek who would rather use keyboard than mouse -- but those are the important bits. Some day I may even make my collection of hacks available to others as reference material. Especially if I get lots of comments requesting such. :-)