Hack 97. Use an iPod with Linux
You don't need a Windows PC or Mac to use an iPod. This hack shows how to use an iPod with Linux. It's aimed at Linux puriststhat is, people who don't want to have to use a Mac or Windows-based PC, nor Wine nor Windows softwareto get going. (I fall into this category, not because of any religious convictions, but merely because Linux is all I have. For updates, visit http://pag.csail.mit.edu/~adonovan/hacks/ipod.html)
Here's what you'll need if you want to use an iPod with your Linux box:
11.7.1. Setting Up Your Linux DesktopAssuming you're using a PCMCIA FireWire card, once the card is inserted, the cardmgr daemon should take care of loading the ieee1394 and ohci1394 modules. If you have a PCI card, these should be loaded by system startup (/etc/rc.local). When you attach the iPod to the FireWire interface, the sbp2 module is loaded automatically. (If it's not, load it with modprobe.) You should see messages appear in dmesg indicating that the device is recognized. Additionally, /proc/bus/ieee1394/devices contains information on each device, including the string [Apple Computer, Inc.] for the iPod: ieee1394: Host added: Node[00:1023] GUID[00d0f5cd4008049d] [Linux OHCI-1394] ieee1394: Device added: Node[00:1023] GUID[000a2700020e545e] [Apple Computer, Inc.] ieee1394: Node 00:1023 changed to 01:1023 SCSI subsystem driver Revision: 1.00 ieee1394: sbp2: Logged into SBP-2 device ieee1394: sbp2: Node[00:1023]: Max speed [S400] - Max payload [2048] scsi0 : IEEE-1394 SBP-2 protocol driver (host: ohci1394) $Rev: 707 $ James Goodwin SBP-2 module load options: - Max speed supported: S400 - Max sectors per I/O supported: 255 - Max outstanding commands supported: 64 - Max outstanding commands per lun supported: 1 - Serialized I/O (debug): no - Exclusive login: yes Vendor: Apple Model: iPod Rev: 1.40 Type: Direct-Access ANSI SCSI revision: 02 Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0 SCSI device sda: 58595040 512-byte hdwr sectors (30001 MB) sda: test WP failed, assume Write Enabled sda: sda1 sda2 The iPod appears as a fake SCSI device (typically /dev/sda if you have no other SCSI devices) and can be accessed using the regular Unix tools for block devices. However, if you are using a Mac iPod, fdisk will not recognize the partition map, and you will get a message resembling "Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel." In this case, it is time to follow the GNU instructions (for conversion). At this point, the Linux IEEE1394 drivers (ieee1394, ohci1394) should have recognized the hardware: % cat /proc/bus/ieee1394/devices Node[00:1023] GUID[001106000000649a]: Vendor ID: `Linux OHCI-1394' [0x004063] Capabilities: 0x0083c0 Bus Options: IRMC(1) CMC(1) ISC(1) BMC(0) PMC(0) GEN(0) LSPD(2) MAX_REC(2048) CYC_CLK_ACC(0) Host Node Status: Host Driver : ohci1394 Nodes connected : 2 Nodes active : 2 SelfIDs received: 2 Irm ID : [00:1023] BusMgr ID : [00:1023] In Bus Reset : no Root : no Cycle Master : no IRM : yes Bus Manager : yes Node[01:1023] GUID[000a2700020ec65a]: Vendor ID: `Apple Computer, Inc.' [0x000a27] Capabilities: 0x0083c0 Bus Options: IRMC(0) CMC(0) ISC(0) BMC(0) PMC(0) GEN(0) LSPD(2) MAX_REC(2048) CYC_CLK_ACC(255) Unit Directory 0: Vendor/Model ID: Apple Computer, Inc. [000a27] / iPod [000000] Software Specifier ID: 00609e Software Version: 010483 Driver: SBP2 Driver Length (in quads): 8 % cat /proc/scsi/scsi Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: Apple Model: iPod Rev: 1.40 Type: Direct-Access ANSI SCSI revision: 02 Performing the HFS-to-FAT32 conversion involves the following steps:
11.7.2. Normal UsageThe Linux drivers for the iPod are still a little flakey; sometimes, the sbp2 driver gets stuck indefinitely in its initializing state and cannot be removed, and at other times the machine hangs. To minimize the risk of such errors, I strongly advise you to follow a disciplined procedure for docking and undocking the iPod. Here's the order of events I usually employ:
Note that these steps are perfectly symmetrical. This seems to achieve greater reliability than performing them in an arbitrary order. I use two scripts, dock-ipod and undock-ipod, whenever I attach or detach the iPod to or from the interface card. Here's dock-ipod: #!/bin/sh modprobe sbp2 mount /dev/sda2 /mnt/ipod/ And undock-ipod: #!/bin/sh umount /mnt/ipod rmmod sbp2 They must both be run as root: % su - root -c ./dock-ipod or: % sudo ./dock-ipod (if the user is a sudoer) or: % su - root Password: root$ ./dock-ipod 11.7.3. Downloaded MP3 Files and ID3 TagsThe iPod does not care about the filenames of MP3 files; all its database information is supplied by ID3 tags within the MP3 files. Therefore, these must be present for transferred files even to appear on the iPod. You might want to add MP3 files that did not come from a CD (e.g., those downloaded from Napster, Kazaa, etc.) to your iPod. The ID3 tags in such files are often inappropriate; for example, because they feature the original artist/album name from the CD they came from, instead of the logical group to which they will belong on your iPod (e.g., Misc/80s Synth Pop). If you do nothing about this, you will find each song appearing in its own artist/album category, with no useful grouping. You'll also need to tag manually when CDDB lookup fails (e.g., for non-industry CDs) or for MP3 files that were hand-encoded from WAV. To change the tags, you'll need a tool such as ID3ed (http://www.dakotacom.net/~donut/programs/id3ed.html; free). This tool is pretty straightforward, and it comes with a helpful man page. The synopsis says: id3ed [-s songname] [-n artist] [-a album] [-y year] [-c comment] [-k tracknum] [-g genre] [-q] [-SNAYCKG] [-l] [-L] [-r] [-i] [-v] files... Obviously, you don't need to include all of those options. Here's an example: % id3ed -s "Red House" -n "Jimi Hendrix" \ -a "Are You Experienced?" -k 3 redhouse.mp3 Alternatively, you can use a graphical tool such as xid3 (www.nebel.gmxhome.de/xid3/; free), which has a Tcl/Tk-based front end for ID3-tag editing that makes it a lot easier to use for this information. The most important ID3 tags for the iPod are Artist, Album, Title, and Track Index (and Genre, if you actually bother to use that). With minimal effort, your iPod will play nicely with Linux. No, you won't be able to buy songs from the iTunes Music Store, but you'll still have most of the functionality Macintosh and Windows users have. Alan Donovan ![]() |