Ipod touch with Linux

Yesterday night I tried to connect the iPod to Linux. I tried some programs but none was working decently; but the good news is that you don't really need any special program "made for iPod" to do this.

For the guys who do not know about iTunes and iPod/iPhone foolishnesses, the problem is that when connecting trough USB they are not exposing the filesystem as usb disk. The second problem is how iTunes memorizes files: they get renamed in 4 char lenght filenames under a 3 char lenght folder... so you have files like:


As result of this, if you have songs belonging to different authors and coming from different albums, but you was keeping in the same folder to listen together... you can't specify to iTunes to play a folder as a playlist, because folder and filenames gets chaotically "reorganized" when imported in iTunes. iTunes, then uses id3 tags to expose views to the user, grouping by author or album title, etc.

To connect to iPod filesystem with Linux, you need to jailbreak the iPhone or the iPod touch, and have OpenSSH running on it. It is not very difficult, but, afaik it's the only way to access remotely to the iPod filesystem, through network (wifi).

Once done that, you need to mount the filesystem using ssh protocol; this can be done with sshfs, which is the ssh protocol support for FUSE (Filesystem in USEr space) which allows you to mount several type of local or remote filesystem without needing root privileges.

$ sudo apt-get install sshfs 

Then I created a folder under my ~/Music folder where to mount my iPod media

$ mkdir ~/Music/iPod 

At last I made a bash script to mount and unmount the iPod media to the folder I just created. This is the content:

#! /bin/bash

case "$1" in
        echo -n foobar | sshfs root@Luigi-R-Viggianos-iPod.local:/private/var/mobile/Media/ ~/Music/iPod -o password_stdin

        fusermount -u -z ~/Music/iPod

	echo "Usage: `basename $0` {mount|umount}"
	exit 1

In the above script "foobar" is the password to use to ssh-connect as root on my ipod. Unfortunately I did not succeed in using public key authentication, even modifying the sshd configuration on the ipod, I do not know why... So I had to specify the password in the script.
The Luigi-R-Viggianos-iPod.local is the hostname used by my iPod. Alternatively you can use the ip address, but when you change network you will need to update the script; the hostname usually gets recognized in different WIFIs and mapped to corresponding ip address.

To get the ip address of the iPod connected to WIFI, there are some programs downloadable on the apple store, one is called, with much of fantasy, "IP Address". To know the hostname of the ipod, just connect to it through ssh, and you will see that displayed on the bash prompt line, in my case: "Luigi-R-Viggianos-iPod:~ root#", unfortunately apples likes to have weird unix system on their devices so you don't have basic commands like 'hostname' or files like /etc/hostname to check... did I already said that I hate OSX...?

At this point what I do is just running the script:

$ ipod mount
$ ipod umount

to mount or unmount the iPod to ~/Music/iPod folder. The iPod needs to be attached to a power source, the laptop trough usb or to a docking station, otherwise it will disable the WIFI connection when it goes on stand by; but the file access is fully wireless.

To play files, you need to launch Amarok or Rhytmbox and import the folder ~/Music/iPod. I use Rhytmbox and it indexes the folder. When the folder is mounted I can see the music on my iPod, and when it is not, the music just disappears.

If you want to export an album of MP3 files from the iPod, you just need to select files from Rhytmbox and drag and drop into Nautilus (filesystem browser). But you will have the weird names for the MP3 files set by iTunes. To batch rename the files you can install and use id3ren, which lets you to customize (-template option) how the filename should be renamed (using album title, song title, author, etc):

$ sudo apt-get install id3ren
$ id3ren -template='%a - %t - %s.mp3' *

If you like to backup the music on your iPod just use rsync or cp. But I don't know how to import new songs in the weird filesystem-format used by iTunes... For this, possibly the easiest solution is to use iTunes on Windows or OSX using VMWare, until Apple does not decide to release iTunes on Linux.

Have fun.

One Response to “Ipod touch with Linux”  

  1. 1 jan

    wau…i did read through your essay and nearly wrote an answer in german…ok…translation :)
    i worked on this problem before, but not with the itunes library, much more with the adressbook, on my ipod touch and osx leopard…i believe, the itunes library also is stored in an sqlite database which is some kind cryptic … i will have a look in the following days…coz i want it sooo badly…syncing over wifi would be great…i’m thinking of adressbook, calendar and music :)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


December 2009
« Nov   Jan »

Follow me

twitter flickr LinkedIn feed

Subscribe by email

Enter your email address:



Tag Cloud