Search:  
Gentoo Wiki

Apple_iPod

Contents

About

This tutorial shows you how to connect an iPod to your Gentoo Linux system. Whether your iPod is Windows-formatted or Mac-formatted, it can work very well with Linux.

If you have a Mac-formatted iPod, then the 2.6.8 kernel works very well with the hfs+ file system.

If you have a Windows-formatted iPod, then you simply need to enable vfat (FAT32) support.

So basically, no matter how your iPod is set up out-of-the-box, it can work with Linux. No further changes are necessary!

Subpages

Compiling The Proper Kernel Modules

Note: This was tested on a 2.6 kernel. If you are using a 2.4 kernel, then you're on your own.

Linux Kernel Configuration: Modules necessary for any iPod
  Device Drivers --->
    SCSI Support --->
      <*> SCSI device support
      <M> SCSI disk support
      <M> SCSI generic support
      [*] Probe all LUNs on each SCSI device
    Input device support --->
      <*> Event interface


If your iPod uses FireWire, you need these modules:

Linux Kernel Configuration: Modules for a FireWire iPod
Device Drivers --->
  IEEE 1394 (FireWire) support  --->
    <*> IEEE 1394 (FireWire) support
    <*> OHCI-1394 support
    <*> SBP-2 support (Hard disks etc.)

If it is USB you need:

Linux Kernel Configuration: Modules for a USB iPod
Device Drivers --->
  USB support  --->
    <M> Support for Host-side USB
    [*]   USB device filesystem
    <M> UHCI HCD (most Intel and VIA) support
    <M> EHCI HCD (USB 2.0) support
    <M> USB Mass Storage support


For Apple formatted iPods you need:

Linux Kernel Configuration: Modules for Apple formatted iPods
  File systems
    Partition Types
      [*] Advanced partition selection (PARTITION_ADVANCED [=y])
        [*] Macintosh partition map support 
  Miscellaneous Filesystems --->
    <M> Apple Extended HFS file system support

Note: If you haven't allready, I still advise you compile the modules for vfat (see below) as well. Vfat is used on most USB-drives such as USB-Sticks etc.

And finally, for Windows formatted iPods you need:

Linux Kernel Configuration: Modules for a windows-formatted iPod
  File systems --->
    DOS/FAT/NT Filesystems --->
      <M> MSDOS fs support
      <M> VFAT (Windows-95) fs support
      (437) Default codepage for FAT
      (iso8859-1) Default iocharset for FAT

    -*- Native language support  ---> 
      (iso8859-1) Default NLS Option
      <M> Codepage 437 (United States, Canada)
      <M> ASCII (United States)
      <M> NLS ISO 8859-1  (Latin 1; Western European Languages) 
      <M> NLS UTF-8    

iPod Partition Scheme

To proceed, you must have some knowledge about your iPod's partition scheme. This can only be done, when the modules are set-up correctly USB/FireWire as mentioned previously.

Plugging in the iPod will result in two things:

  1. The "Do Not Disconnect" message on the iPod's screen.
  2. The one of the following dmesg outputs, depending on USB/FireWire choice.

FireWire will give you something like this:

Code: dmesg on FireWire iPods
scsi1 : SCSI emulation for IEEE-1394 SBP-2 Devices
ieee1394: sbp2: Logged into SBP-2 device
ieee1394: Node 0-00:1023: Max speed [S400] - Max payload [2048]
  Vendor: Apple     Model: iPod              Rev: 1.63
  Type:   Direct-Access                      ANSI SCSI revision: 02
sda: Spinning up disk........ready
SCSI device sda: 39063024 512-byte hdwr sectors (20000 MB)
sda: Write Protect is off
sda: Mode Sense: 04 00 00 00
SCSI device sda: drive cache: write through
 /dev/scsi/host1/bus0/target0/lun0: [mac] p1 p2 p3
Attached scsi removable disk <font color=red>sda</font> at scsi1, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi1, channel 0, id 0, lun 0,  type 0

A USB iPod gives something like this:

Code: dmesg on USB iPods
usb 1-3: new high speed USB device using ehci_hcd and address 3
usb 1-3: configuration #1 chosen from 2 choices
Initializing USB Mass Storage driver...
scsi0 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 3
usb-storage: waiting for device to settle before scanning
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
  Vendor: Apple     Model: iPod              Rev: 1.62
  Type:   Direct-Access                      ANSI SCSI revision: 00
usb-storage: device scan complete
SCSI device sda: 3999744 512-byte hdwr sectors (2048 MB)
sda: Write Protect is off
sda: Mode Sense: 68 00 00 08
sda: assuming drive cache: write through
SCSI device sda: 3999744 512-byte hdwr sectors (2048 MB)
sda: Write Protect is off
sda: Mode Sense: 68 00 00 08
sda: assuming drive cache: write through
 sda: sda1 sda2
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0

Mounting Your iPod

For this you need to know the device name of your iPod. Once again, the dmesg command helps. If you have no other SCSI, SATA or USB/FireWire-mass storrage devices, the device-name is likely "sda", if you do, it is probably "sdc" or "sde". You should also see the corresponding entries in /dev (i.e. /dev/sda1).

Next, if you are using a PC-formatted iPod, then you have two partitions. You should therefore mount the second partition ("sda2"). If you have a Mac-formatted iPod, then you have three partitions, and you should mount the third one ("sda3").

mkdir /mnt/ipod
mount -t hfsplus /dev/sda3 /mnt/ipod
mkdir /mnt/ipod
mount -t vfat /dev/sda2 /mnt/ipod

For a fat32 formatted iPod the following line in /etc/fstab will instruct the computer to mount /dev/ipod on /mnt/ipod:

File: /etc/fstab
...
# for Apple formatted iPods change vfat to hfsplus.
/dev/ipod  /mnt/ipod  vfat  async,nodev,nosuid,user,rw,noauto 0 0
...

To enable the iPod to be written to by other users, you need to adjust the above line:

File: /etc/fstab
...
/dev/ipod  /mnt/ipod  vfat  async,nodev,nosuid,user,rw,noauto,umask=0000,noexec  0 0
...
Warning: The old suggested sync is a very slow option (actually, potentially dangerous as it could destroy a flash drive if it's formatted in vfat), async is much faster (200KB/s as opposed to 5-10MB/s.) If you originally used sync change it to async for a very significant speed increase. However with async, the iPod must be unmounted before detachment from computer or there will be data loss.
Warning: It is Essential that you NOT format your iPod with hfs+ journaled! This will happen if you first use your iPod on OSX which has support for HFS+ Journaling. To safely access it the first time, use Amarok or GTKpod.

Using udev with the iPod

The advantage of this is that your iPod will always be /dev/ipod, regardless of the order you plug devices in. This helps by not referencing a set /dev/sd* or /dev/ub* in /etc/fstab -- which allows you to mount your iPod on /mnt/ipod without checking if the iPod was assigned the same device. This gives us more of a "plug-n-play" feel, and limits conflicts with other drives.

The procedure for setting up udev with the iPod has changed since udev version ???. See below for the old procedure.

To use udev first create a file called /etc/udev/rules.d/60-ipod.rules and add this line:

File: /etc/udev/rules.d/60-ipod.rules
  SUBSYSTEMS=="scsi", KERNEL=="sd?2", ATTRS{vendor}=="Apple*", ATTRS{model}=="iPod*", SYMLINK+="ipod", GROUP="plugdev"

Note: /etc/udev/rules.d/50-udev.rules is read before the ipod rules if using 60. If udev rules are applied first, it allows the ipod rules to overide them when they are applied. This allows you to add GROUP="plugdev" to the above rule (plugdev being a group on the system where users who may eject your ipod are listed). If your ipod rules are run first, the udev rules will overide any GROUP you set and set the group ownership to "disk" for /dev/sd* which only root can eject. In short, having your ipod rules run later will allow you to set the group ownership to a more useful group.

Restart udev

In order for our changes to become effective, we must restart udev. To do this, issue the following command, as root:

# udevtrigger

Using old udev with the iPod

This procedure is for setting up udev versions prior to ??? with the iPod. See above for the new procedure.

Using FireWire (IEEE-1394) with the iPod

To use udev first create a file called /etc/udev/rules.d/60-ipod.rules and add this line:

File: /etc/udev/rules.d/60-ipod.rules
  BUS=="scsi", SYSFS{vendor}=="Apple*", SYSFS{model}=="iPod*", SYMLINK+="ipod"

Using USB with the iPod

Apple has removed the FireWire component from newer iPod models, so you are forced to use USB to sync your iPod. The following udev rule may be used to properly create the dynamic /dev/ipod symlink:

File: /etc/udev/rules.d/60-ipod.rules
  BUS=="usb", SYSFS{manufacturer}=="Apple*", SYSFS{product}=="iPod*", SYMLINK+="ipod"

Note: Of course, you have to adjust the line in /etc/fstab accordingly (see above).

Note: If udev incorrectly links your ipod to /dev/sd*1 instead of /dev/sd*2 (or you have a different partition layout, like beacuse of the use of ipodlinux), add KERNEL=="sd*2" before the SYMLINK parameter.

Note: /etc/udev/rules.d/50-udev.rules is read before the ipod rules if using 60. If udev rules are applied first, it allows the ipod rules to overide them when they are applied. This allows you to add GROUP="plugdev" to the above rule (plugdev being a group on the system where users who may eject your ipod are listed). If your ipod rules are run first, the udev rules will overide any GROUP you set and set the group ownership to "disk" for /dev/sd* which only root can eject. In short, having your ipod rules run later will allow you to set the group ownership to a more useful group.

Restart udev

In order for our changes to become effective, we must restart udev. To do this, issue the following command, as root:

# udevstart

Unplug your iPod

Finally, to plug-out your iPod safely execute those commands :

 umount /dev/ipod (optional, eject should also umount)
 [sudo] eject /dev/ipod

Note: If you set a GROUP in the udev rule and have your ipod rules run after the udev rules as mentioned above, the sudo command will not be needed (prove it with an example)

Troubleshooting

UTF8/Unicode Song Tag Problems

Some of you who find that your unicode songs show fine in amaroK and similar programs, may also find that konqueror and gtkpod may have issues copying them over. The problem is usually caused by the charset encoding not being specified during the writing of the id3 tag, but there's a script to solve this problem that can be found here.

It requires a special library called MP3::Mplib which will not compile readily at the time of this writing. There are a few fixes you must do to compile it.

  1. Download the MP3::Mplib source code
  2. Untar the folder contained, and change directory to it
  3. `cp t/test.mp3 t/test_cp.mp3`
  4. Open `t/t2.t` and comment out(by putting # in front) lines 25 and 26 containing the 5th test. Then change the number '5' on line 8, to '4' and save and close the file.
  5. `perl Makefile.PL`
  6. `make`
  7. `make test`
  8. Change to superuser, and `make install`

Voila! Now you're ready to use the script. Simply execute it with `perl foobar.pl some.mp3` and tada, the file is ready to be shoved onto the ipod =)

Note: Alternative method for the adventurous: (as root) perl -MCPAN -e "install MP3::Mplib"

Problems with Fifth Generation iPods

HFS+ Problems

If you are having problems mounting the iPod in read-write mode, check:

It comes like that from factory, disable it through the MacOS X tool DiskUtil (from commandline)
Likely if you started using it from MacOS X. Correct it changing your userID to the same number, or through chgrp and chown.
hfs: Filesystem was not cleanly unmounted, running fsck.hfsplus is recommended.  mounting read-only.
I found out that fixing it with fsck.hfsplus before mounting made the trick. It still would come up with the same problem next time I plugged the iPod, thogh. So I've modified my udev rules to make it to happen automagically:
File: /etc/udev/rules.d/10-local.rules
BUS=="usb", SYSFS{manufacturer}=="Apple*", SYSFS{product}=="iPod*", ACTION=="add", SYMLINK+="ipod", RUN+="/sbin/fsck.hfsplus -r /dev/ipod"
It works perfectly now! ;-)

Using Windows and iTunes

This was not always the case, but has increasingly become so in recent times. If you purchase a new iPod and perform a full restore from a Windows iTunes installation, it will mount and operate cleanly on Linux. The only things you need for this to work are the vfat kernel modules and code pages, and appropriate support for USB or FireWire external hard drives.

This is obviously not a preferred method due to its proprietary nature, but it's remarkably safer, and if you do brick your iPod by means of a messy firmware update or the like, it's likely you'll end up doing this anyway.

Mounting Problems

If you are getting a message like

$ mount -t vfat /dev/sdc2 /mnt/ipod
mount: wrong fs type, bad option, bad superblock on /dev/sdc2,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so 

Then double-check your Kernel Configuration (#Compiling The Proper Kernel Modules) and make sure the iPod is formatted correctly.

See also

Retrieved from "http://www.gentoo-wiki.info/Apple_iPod"

Last modified: Sun, 07 Sep 2008 00:29:00 +0000 Hits: 92,774