Gnuru.org
Productive Linux


Subscribe

 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Login
Login:
Password:



Don't have an account?
Sign up to Gnuru.org
Forgot your password?

iPod touch, iPhone and Linux - Making it All Work
8 March 2011 @ 21:36 GMT
by Paul

There's nothing like an iPod; sleek, beautiful, pleasing to the eye, and totally useless thanks to Apple's insistence on trying to stop you doing what you want with your devices. Are the iPod touch and iPhone two of the most useless devices ever to come from a tech company?

I had previously managed iPods using the excellent gtkpod, but the iPod touch is a different matter. Unlike other iPods which just mount as disks, the iPod touch doesn't. Apple in their infinite idiocy decided to encrypt the iPod touch like they do all iPhones. The iPod touch and the iPhone are very similar; essentially the iPod touch is sort of an iPhone without the 'Phone' bit. I guess that just makes it an 'i'.

Here's what I learned by getting an iPod touch working with Linux.

Mount the iPod touch or iPhone as a fuse device

Before we start, I need to mention that you need the fuse ("Filesystem in Userspace") kernel modules. You also need the ifuse package, which provides a means of communicating with iPhone type devices.

sudo aptitude install ifuse

You will probably also need to make a mount point for the iPod touch or iPhone. Make it somewhere sensible, like under the /media/ directory.

sudo mkdir /media/iPod

You must, must, must make sure that the mount point is writable by the user going to administer the iPod touch. There are lots of ways to do this, but I did:

sudo chown me /media/iPod

Now, make sure that your user is in the 'fuse' group. If necessary do:

sudo adduser me fuse

Once done log out and log in again. Make sure the iPod touch or iPhone is connected to the computer and mount it:

ifuse /media/iPod/

You can then unmount it by doing:

sudo umount /media/iPod

If on the other hand you do:

ifuse --root /media/iPod/

You get access to the iPod's root directory. Once you do that, you might be amazed at the elegance of the BSD base of the iPod's operating system. It's such a pity Apple cripples it.

It's cool if all that works for you, unfortunately, it didn't work for me. Instead I got the following error:

Failed to start AFC service 'com.apple.afc2' on the device. This service enables access to the root filesystem of your device. Your device needs to be jailbroken and have this service installed. Note that PwnageTool installs it while blackra1n does not.

Although I could browse the iPod file system, I could neither play, copy nor save files. In essence the iPod was useless unless I jailbroke it.

Jailbreaking the iPod touch and iPhone

WARNING: DOING ANY OF THE BELOW MAY VOID YOUR APPLE WARRANTY AND COULD DAMAGE YOUR IPOD OR IPHONE

Jailbreaking sounds so cool, unfortunately it is totally legal in the US and throughout the EU so that little frisson of excitement that I got with the thought I might perhaps be skirting around the edge of the law, was totally unjustified. On the plus side, jailbreaking iPhones and iPod touches really gets up the nose of Apple, which certainly gave me a mild sense of satisfaction. Have I mentioned how much I hate Apple?

Most jailbreaking, also known as 'privilege escalation' applications are for Macs and some for Windows. But they do exist for Linux. The one I used was Spirit Jailbreak, which is an amazingly cool piece of software. Binaries aren't available only the source code. So it needs compiling and you need to install relevant developer libraries:

sudo aptitude install libgpg-error-dev
sudo aptitude install libimobiledevice-dev
cd ~/src/  # or wherever you like to keep source files
git clone https://github.com/posixninja/spirit-linux.git
cd spirit-linux
make

Once that is done we have the spirit binary, which you run like this:

./spirit

The jailbreak worked like a dream for me. After running spirit the Cydia icon appears on the iPod desktop. Cydia is the app store for apps that Apple don't approve of. So, any self-respecting geek needs it.

On the iPod, touch the Cydia icon and navigate around until you find 'MobileTerminal' which gives you a command line on the iPod. Install it. Then find 'OpenSSH', which provides ssh software, obviously, and install that too.

Also, use the Cydia appstore to install afc2add to install the afc service to the iPod. When this is installed touch the "REBOOT" button.

Now that you have jailbroken the iPod, you need to change both the root password and the password of the sole user. The name of the user is 'mobile'. The root password is always 'alpine'.

To do this, touch the Terminal icon (which appeared when you installed MobileTerminal). A command line will appear as will a keyboard. On the keyboard type 'su' and give the root password ('alpine' if you weren't paying attention). Now type 'passwd', and you will be prompted to enter the new password twice. Now, type passwd mobile and choose a new password for the user.

At this point, the iPod touch or the iPhone is properly jailbroken and has been promoted from useless piece of electronic crap to interesting computing device.

Finding and storing the FirewireGuid

There was still a problem. gtkpod could copy music files across to the iPod touch, but it couldn't write to the iPod database, so the iPod couldn't see the music that was on its hard disk.

The reason for this was:

Starting with the 2007 generation of iPods, libgpod needs an additional configuration step to correctly modify the iPod content. libgpod needs to know the so-called iPod "firewire id", otherwise the iPod won't recognize what libgpod wrote to it and will behave as if it's empty.

The first step to fixing this was to get the 40-character unique identifier for the iPod. On your Linux computer do:

lsusb -v | grep -i iSerial

Something like this should appear:

iSerial 3 2fffccffda5c69bc16ea3fc1e53537259ff4a514

The first 16 digits of this is the FirewireGuid. On the iPod there should be a Device/SysInfo file. If not we create it:

cd /media/iPod/iTunes_Control
mkdir Device
echo "FirewireGuid: 2fffccffda5c69bc" > Device/SysInfo

After doing all that, when I restarted gtkpod, everything was be working.

Final Thoughts

Using these steps I was able to get gtkpod to read and write to the iPod and I can add and delete music from this originally defective-by-design piece of machinery.

A big thanks to the writer of Spirit Jailbreak, to the developers of gtkpod, of fuse and of everything on Linux that make it possible to conquer Apple's products.

TIPS:

  • make sure you have the latest version of libgpod4
  • ifuse –root /media/mountpoint mounts the iPod's root file system
  • you can backup all the files on the iPod with rsync -aP /media/iPod /backup/dir
  • reconcile the files on the iPod HD and in the iPod DB with gtkpod's 'Check ipod files' command



Hi there, thank you very much for this tutorial. I've been able to do everything listed here but when I sync music with my iPod 4g Os 4.3.3 i get the error:

Unsupported Checksum Type


Posted by sade on 2011-07-21 20:34:00.
Comments disabled