Translation(s): English - Français - Castellano - Italiano


This page describes how to connect an iOS device (e.g. iPhone, iPod Touch, iPad) to a Debian Squeeze (DebianSqueeze) or Wheezy (DebianWheezy) system. The terms "iPod" and "iPhone" are used interchangeably in this document. Note that older model iPods that do not run iOS are well-supported by a simple installation of gtkpod -- you need not go through all this hassle to connect an older-model iPod.

This page does not describe how to install a Debian OS on an apple device.

Getting Started - Backup your data

* These instructions explain how to set up your iPhone so that you can sync (copy music) from Debian Squeeze or Wheezy using a program such as gtkpod, Rhythmbox, amarok or banshee. Doing so should not disrupt your iTunes sync-- even after adding music, you should still be able to access the device using iTunes. That said, keep in mind: 1. this is free software; 2. it comes with no guarantee, and 3. it is possible that a bug could exist that could delete your music and other files. Most of us haven't had such issues, but we advise that you back up your data before starting.

Configure the iPhone, part 1

* Once configured, your iPhone should work on any GNU/Linux machine, without needing to rerun this configuration. (Provided the GNU/Linux machine has the necessary packages installed.)

* If the iphone already has music on it, you may skip to the next step

  1. Create an initial audio database, if one does not exist already.
    1. Plug the iPhone into an MS Windows or Mac OS X computer
    2. Fire up iTunes
    3. Add at least one song or free podcast to the iPhone.

* This initializes a database on the iPhone which is needed for the rest of the instructions to work.

[There may be a way to copy an initial database file using only Debian; if you know how, please edit this wiki page.
The libimobiledevice homepage mentions a project called ideviceactivate.]

Connect the iPhone

* If your iPhone has a recent version of iOS (5 or later? Maybe 4.3? 4.2.1?) then you will need libimobiledevice 1.1.1 or later, available in Wheezy. Squeeze has libimobiledevice 1.0.2, which will not work with recent versions of iOS. There is a rather involved backport, described below. It's probably a good idea to first proceed with the normal installation, before attempting the backport. If the normal installation doesn't work (nowadays usually due to an "unhandled lockdown error") then you can try the backport.

  1. Install several packages:
    • aptitude install libimobiledevice-utils gvfs-backends gvfs-bin gvfs-fuse

  2. As root, edit the file /etc/fuse.conf:
    Uncomment (remove the # symbol from) #user_allow_other at the end of the file.
    If you can't find the line then simply make a new line at the end of the file that reads user_allow_other.
    Save the file! If you are not root then you will not be able to save it, and you will have to do it again, as root.

  3. Ensure that your user is a member of the fuse group: as normal user, type groups and look for "fuse". If not, then:

    1. Add your user to the fuse group. I'll use "sheila" as an example; replace sheila with your username.

      usermod -aG fuse sheila
      [You should do this for each user on your system that should be able to connect iPhones to the computer]
      [Alternately you can use a GUI tool like Gnome's System → Administration → Users and Groups]

    2. After adding your user to the fuse group, log out and log back in. If your GNOME session (or other desktop session) was started before your account was added to the "fuse" group, then your environment does not yet include the fuse group; thus you will not be able to run programs that require group "fuse" permissions.
  4. Pray. :-) If the next step does not work then there may be some significant challenges ahead.

  5. Connect the iPhone.
  6. Hit Cancel if you are asked to open it as a camera to import pictures;

  7. Alternately, if you get an option to do an AFC or music mount, then you can do that.
  8. If you are lucky, the iPhone will appear on the desktop, with its name (e.g. "Sheila's iPhone" or "iPhone of Sheila").
  9. By default, it is mounted in ~/.gvfs (e.g. for sheila, /home/sheila/.gvfs/iPhone of Sheila)

  10. If you are not so lucky -- that is, you don't see anything on the desktop, and ~/.gvfs/iPhone does not exist -- then you should do a little troubleshooting.
    It may be that you are simply not running an automount daemon, or the problem may be more difficult. Go to the Mount Troubleshooting section.
    Tip: if you prefer to mount via the command line rather than with auto-mount daemons, see the mount script.

Configure the iPhone, part 2

* If you are running Wheezy or later, the following happens automatically, and you can skip to the next section.

* Start up a terminal: this section will be performed on the command line. You should be a normal user-- not root or sudo

  1. First download and set up the mount script and then come back here.

  2. Assign the serial number of your iPhone to a variable called $serial. Note serial= is correct, $serial= will not work

    serial=$(./mount-iphone.sh echo_serial)

  3. Verify that the variable was properly assigned

    echo $serial
    If this doesn't show the serial number, go back up-- the next steps will not work.

  4. cd to your home folder. (if you type cd by itself, it will bring you to your home folder)

    cd

  5. cd into the iphone's mount point folder

    cd .gvfs
    cd "iPhone of Sheila"
    note: the double-quotes are important, if the name has spaces or apostrophes or other special characters in it
    Tip: tab-completion is a handy terminal tool. Type cd iP and then press the TAB key.

  6. moving along...

    cd iTunes_Control
    ls

  7. Does the ls above show a directory called Device?

    1. If not, then

      mkdir Device

  8. Return to the parent directory (e.g. "~/.gvfs/iPhone of Sheila")

    cd ..

  9. Make sure you're in the base directory of the iPhone

    pwd
    The above should output, for example:
    /home/sheila/.gvfs/iPhone of Sheila
    If not, then get into that directory. The next step depends on it.

  10. Use the following command (from libgpod-common) to create iTunes_Control/Device/SysInfoExtended:
    ipod-read-sysinfo-extended $serial $PWD

  11. Check for the new file

    ls -l iTunes_Control/Device/SysInfoExtended

* Your iPhone is now ready to interface with libgpod and all the tools that use it, like gtkpod, rhythmbox, amarok, banshee, etc.! You can use these tools on any modern linux computer to add and delete music from your iPhone, in addition to your iTunes sync computer, without destroying the playlist.

Using Rhythmbox

  1. First, install it:

    aptitude install rhythmbox rhythmbox-plugins

  2. Log out and log back in again.

    (It's not clear why this is necessary, but may fix the problem if you get an error when attempting to mount the along the lines of:
    "Error: DBus error org.freedesktop.DBus.Error.ServiceUnknown: The name :1.41 was not provided by any .service files".
    )

  3. Launch Rhythmbox:

    Applications → Sound and Video → Rhythmbox

  4. Find the iPhone on the left panel
  5. Click on the iPhone to see what music is on it
  6. You can now Drag-and-Drop files between the iPhone and your rhythmbox music collection, similar to the way you would in iTunes and other programs.

* NOTE: Older versions of rhythmbox may have a difficult time syncing the iPhone properly. Some of us have had real difficulties with music we put on the device not ever showing up. Gtkpod seems to sync more reliably.

* The following may help:

  1. Use rhythmbox's rightclick menu to eject the iPhone, and wait for some time while it syncs
  2. Connect the iPhone to your iTunes computer and cancel the "cancel sync" operation
  3. Install gstreamer1.0-plugins-* (all of them... this seems to help some people)
  4. ??? not sure what else

mount-iphone.sh script

* Some people do not have an automount daemon in their DE; some others simply prefer to mount things manually.

* This script is also very useful for the section, "configure the iPhone, part 2"

  1. Script is here: mount-iphone.sh
    (clicking the link takes you to an "Attachment page" where you can "Download" the script)

  2. Open a terminal
  3. Navigate to the directory where you saved the script
  4. Set the execute bit:

    chmod +x mount-iphone.sh

* For those who prefer to simply copy a few commands, the script basically does this:

* Now it is time to try running the script.

  1. First run it with no parameters, to see if it detects the iPhone

    ./mount-iphone.sh
    If you see something like,

    • fb9961044533cd317cb6f2bce3424c2771ae16d6 is mounted
      or
      fb9961044533cd317cb6f2bce3424c2771ae16d6 is not mounted
      ...then that's good!

  2. If it is not yet mounted, you can mount it like so:

    ./mount-iphone.sh mount

  3. If all is well, you will see a message like this:

    mounted iphone with serial fb9961044533cd317cb6f2bce3424c2771ae16d6
    (note, your serial number will be different)

  4. Alternately, you might see an unwelcome error message such as the following:

    Unhandled lockdown error (-5)
    If you get an error, go to the Mount Troubleshooting section.

* If it worked correctly, you may want to go back to Configure the iPhone, part 2.

Here is the script inline, for reference convenience: (skip to the Next Section)

# debian's wiki system seems to prohibit a code section starting with #! - so delete the two lines before #!/bin/bash ;)
#
#!/bin/sh
#
# mount-iphone.sh
# This script attempts to mount or unmount the first connected ipod/iphone.
# Usage: ./mount-iphone.sh [mount | umount | echo_serial]
# It should be dash-friendly
#
# Written by Mohamed Ahmed, Dec 2010
#
# Refactored and extended by David Emerson, Feb 2012
#
# You can configure send_msg to use either a console echo, or notify-send.
# notify-send is part of the debian package, libnotify-bin
# The apple pictures in /usr/share/pixmaps are part of the gnome-desktop-data package
#
# uncomment the following if you want to see the mount command used:
# show_mount_cmd=1

# you can uncomment this line to see all the commands sh executes:
# set -x

show_msg ()
{
  # notify-send -t 4000 -u normal "mount-iphone" "$1" -i "/usr/share/pixmaps/apple-$2.png"
  echo "$1" >&2
}

get_device_ids ()
{
  # get the Apple vendor id (idVendor) from lsusb
  idVendor=$(lsusb -v 2>/dev/null | awk '/idVendor.*Apple/{print $2; exit}')
  [ -z "$idVendor" ] && { show_msg "Cannot find any Apple device" "red"; exit 1; }
  # get the device serial number (iSerial)
  iSerial=$(lsusb -v -d $idVendor: 2>/dev/null | awk '/iSerial/{print $3; exit}')
  [ -z "$iSerial" ] && { show_msg "Cannot find serial number of Apple device $idVendor" "red"; exit 1; }
}

is_mounted ()
{
  gvfs-mount -l | grep -i "mount.*$1" >/dev/null
}

mount_iphone ()
{
  [ -z $show_mount_cmd ] || echo gvfs-mount afc://$1/ >&2
  if gvfs-mount afc://$1/; then
    show_msg "mounted iphone with serial $1" "green"
  else
    show_msg "iphone mount failed" "red"
    exit 1
  fi
}

unmount_iphone ()
{
  ## now gvfs unmount the device
  [ -z $show_mount_cmd ] || echo gvfs-mount -u afc://$1/ >&2
  if gvfs-mount -u afc://$1/; then
    show_msg "unmounted iphone with serial $1" "red"
  else
    show_msg "iphone umount failed" "red"
    exit 1
  fi
}

case $1 in
  mount)
    get_device_ids
    is_mounted && { show_msg "$iSerial is already mounted" 'green'; exit; }
    mount_iphone $iSerial
    ;;
  umount|unmount)
    get_device_ids
    is_mounted || { show_msg "$iSerial is not mounted" 'red'; exit; }
    unmount_iphone $iSerial
    ;;
  echo_serial)
    get_device_ids
    echo $iSerial
    ;;
  '')
    get_device_ids
    is_mounted && show_msg "$iSerial is mounted" 'green' || show_msg "$iSerial is not mounted" 'red'
    ;;
  *)
    echo "Usage: $0 [mount | umount | echo_serial]"
    exit 1
    ;;
esac

exit 0

Mount Troubleshooting

* If you are here, then chances are you had trouble mounting the device. If not, then you need not be here...

  1. The first troubleshooting action to take is to set up the Mount Script, above. Do that!

  2. Try and mount

    ./mount-iphone.sh mount

* If you get an Unhandled lockdown error, the cause for this error can be varied:

* Other errors... please help expand the wiki!

backporting libimobiledevice 1.1.1 to Squeeze

backporting caveats

* As of 2014-Mar there is no official backport. It would be great if there was! You should check for one before doing this. Really. http://backports.debian.org/Packages/ - search for libimobiledevice in squeeze-backports and squeeze-backports-sloppy

* If someone has backported libimobiledevice 1.1.1, then please make mention of it here.

* Don't delete this section, though, as it may very well be useful to someone in the future, for reasons unknown and unexpected to you now.

* Unfortunately, after performing this backport, Squeeze's rhythmbox is still a little buggy, and is not very reliable about putting music on the iPod. Note the issues mentioned in the rhythmbox section. You can definitely use it to get music FROM the iPod, though!

* Squeeze's gtkpod doesn't seem to work at all. However, it is relatively easy to compile gtkpod 2.0.2 from snapshot.debian.org, and that seems to work pretty well with iOS 5!

* In order to proceed with building this backport, you must be comfortable with the following:

  1. manipulating /etc/sources.list - making multiple changes
  2. modifying source files
  3. building debian packages using dpkg-buildpackage
  4. installing debs
  5. patiently following all the steps in order

* NOTE: this works with libimobiledevice 1.1.1-3, available 2012-Feb-16. If, by the time you try this, wheezy has moved to a later version of libimobiledevice, and it does not work, then your best bet may be to get libimobiledevice 1.1.1 from http://snapshot.debian.org - refer to the gtkpod 2.0.2 instructions, below.

* Alright, if you're still with me, let's get started...

step-by-step instructions for the backport

* As you can see, this backport is not for the faint of heart. Good luck!

List of Programs

List of Tools

Tools and programs useful to iPhone users in debian

Orphan:


CategoryPhone