Using an iPod in Linux

What can you do with an Apple iPod and Linux that you can't do with Apple's iTunes? Plenty.

then it's a good idea to add a line manually to your /etc/fstab file that indicates this:

/dev/sda2 /mnt/ipod vfat rw,user 0 0

Remember that for the disk-based iPods, you want to mount only the large music-holding partition (sda2) and not the smaller partition that holds the OS (sda1). For the iPod Shuffle, which has one partition, an entry like this should do the trick:

/dev/sda1 /mnt/ipod vfat rw,user 0 0

If you haven't done so already, make the mount point /mnt/ipod by running mkdir /mnt/ipod as root.

By default, GTKPod looks for your iPod to be mounted at /mnt/ipod, but you can change this value. The easiest way to mount your iPod is to let GTKPod do it for you. To do this, start up GTKPod and select Edit then Edit Preferences. In the Input/Output tab, check the box that says Handle mounting/umounting of iPod drive. Start up GTKPod again, and your iPod automatically is mounted for you.

GTKPod has many options and features, and the best way to get your feet wet is to put some music on the iPod. Chances are, you've already got buckets of MP3 files on your computer. GTKPod only handles managing files on the iPod. Too create MP3s, you need to use a separate program, such as Grip. To listen to the MP3s, GKTPod relies on an external program such as XMMS; you can specify your favorite MP3 player in GTKPod's preferences.

Once you've got some MP3s to transfer, you can use the Add Files button to add single files or the Add Dirs button to add an entire directory at one time. Figure 1 shows the Beastie Boys' album Hello Nasty being added to my freshly formatted iPod. When you click the OK button to add a directory, GTKPod then processes the files, adds them to your local iTunes database (in ~/.gtkpod/ by default) and lists them by artist, title, album or genre in the lower window pane. The next step in the process is to click the Sync button. This step does the actual transfer of files from your PC to the iPod; it also syncs your local iTunes database on the PC to the one on your iPod. It takes a minute or two to accomplish, depending on how much music you're moving over. When your files have been moved over successfully, GTKPod says “iPod Database Saved” in the lower left-hand corner.

Figure 1. GTKPod organizes your music by all the usual attributes and lets you create playlists.

Don't remove that iPod yet, though. If the iPod still says “Do not disconnect” or if your Shuffle's status light still is blinking orange, then leave it connected. Consider that your iPod has been mounted as a removable hard drive. You wouldn't unplug a spinning hard drive from your system, would you? You first need to make sure the iPod is unmounted. If you're using the automatic mounting within GTKPod, simply exit GTKPod and the iPod is unmounted.

At this point, your iPod still should be flashing the “Do not disconnect” warning. It's only safe to unplug your iPod when this message is gone. The way to remove this message is to unload the kernel module that handles removable hard drives. If you're using Firewire, the module is sbp2, which can be removed by giving the command modprobe -r sbp2 in a root terminal. Only when the “Do not disconnect” message is gone and you see the normal iPod menu should you disconnect it from your PC.

With GTKPod, you have the ability to execute scripts automatically every time you start or stop the program. The files ~/.gtkpod/ and ~/.gtkpod/gtkpod.out—or /etc/ and /etc/gtkpod.out if these files are not in your home directory—are read and run when starting up or exiting GTKPod. In the case of start up, the script is run before your iPod is mounted. So, if you need to load kernel modules or otherwise massage your system before using your iPod in Linux, this is the place to do it. Likewise, putting scripts in a gtkpod.out file can make removing your iPod a snap.

Once your iPod is removed, you should be able to play all of the tracks you transferred. If things didn't work out as planned, check the troubleshooting section of this article or the on-line Resources section for help. If things did work out, you're going to want to add some more music. And once you've added some more music, you'll want to explore some of GTKPod's features for managing your tunes.

To manage the files on your iPod, use the Read button in GTKPod to read the contents of the iTunes database on your iPod. You now should see your recently added tunes. The far left pane shows which playlist is selected. A playlist is exactly what it sounds like it is—a list of songs grouped to be played together. The tabbed window panes show the music on your iPod as listed in its iTunes database and displayed according to the selected tabs. By default, there are two panes, but you can edit your preferences to add more. I've added one pane for a total of three so I can sort through my music with a finer-toothed comb.

Creating playlists gives you the ability to be your own DJ and play the mixes you want when you want to hear them. I don't know about you, but nothing brightens my day quite like that old-school East coast rap. So I'm going to create a playlist for those dark days in the office when I need more of a pick-me-up than a cup of coffee can provide. I click on New PL to create my Old Skool Rap playlist and then use GTKPod to sort through my music to select the proper songs (see Figure 2). With the additional sort window pane, I can sort by genre, artist and then year. I want to hear the Beastie Boys, but only the old stuff, so I click on 1986 and drag and drop it onto my new playlist, and 13 files are copied. Now I move down to RUN-DMC and do the same. By now, I realize that I don't have enough rap ripped, so I need to fire up Grip and get to work.

Figure 2. Building a playlist is as easy as drag and drop.

If you already are using another application to generate playlists, you still can use those playlist files in GTKPod. GTKPod should have no trouble adding preexisting .m3u or .pls files as playlists. Simply click New PL, name your playlist and then click Add File and find your playlist file to add. GTKPod also lets you export an existing playlist to m3u format.

One of my favorite features of GTKPod is the ability to edit the ID3 tag of MP3s on the iPod as well as those on your PC. The ID3 tag is the portion of the MP3 file that contains metadata such as the artists name, album name, song name and the year the album was released. You can name an MP3 file absolutely anything in the world, and GTKPod and your iPod still list it based on the ID3 tag. On the other hand, if your MP3 file lacks the ID3 tag for some reason, it is not listed correctly and shows up under a blank heading in GTKPod or under the All heading on your iPod. To fix this, simply click on the section you want to edit in GTKPod and type away.

If you click on an individual song in the lower window pane, you edit the ID3 tag for that song only. If you want to edit the same field for an entire group of songs, click and edit that field in one of the sort window panes and the changes are reflected for all songs in the bottom window pane. You also can use the Multi-Edit function to edit ID3 tags for several files at once. This feature is optional and must be enabled within your preferences, but it allows you to select several songs at once—highlighting them using the shift key as in Windows—and have the edit for one field, for example, artist, apply to every selected song.

Another great feature of GTKPod that you won't find in Apple's iTunes software is the ability to export songs, copying them from the iPod back to your computer. Of course, this could be done simply by mounting the iPod as an external hard drive and rooting around until you find the exact songs to copy off, but it's much easier to use GTKPod to sort and select the songs to copy. Look under the File menu, then Copy Tracks from iPod. The Delete Completely From iPod option under the Edit menu works as advertised, freeing up precious megabytes from your iPod should you need more space for this week's favorite flavor of music.

One feature notably lacking from GTKPod is the ability to manage music purchased from the iTunes music store. This iTMS music is compressed using the AAC format and then laced with a bit of DRM technology to limit what you can do with it. If you've purchased a lot of music from iTunes and you want to manage it with GTKPod, you've got two options. The first is to use iTunes to burn the music to a CD, then re-rip it using a tool such as Grip. This works, but unless you burn and rip an entire album at a time, the CDDB database doesn't know what to make of your freshly burned CD, and you wind up adding all of the ID3 tags manually. The second option is to use a program such as Hymn to strip all of the DRM ugliness from the music that you purchased. Be warned that because Hymn circumvents DRM, it may not be legal to use if vendor lock-in laws such as the US' Digital Millennium Copyright Act exist in your country.

If you're not much for GUIs and you prefer the simple elegance of a shell prompt, consider GNUpod, a collection of Perl scripts that makes managing the music on your iPod easy. GNUpod's tools do everything from creating the directory structure that holds music on the iPod, to adding or deleting music and managing playlists. It does all this from the command line by passing arguments to various Perl scripts, such as this one: -m /mnt/ipod /tunes/rappers_delight.mp3

GNUpod installs in a snap. The on-line documentation provided by the GNU folks is comprehensive and walks you through everything from getting Firewire working to re-formatting your iPod. At the time of this writing, GNUpod supports all flavors of iPods including the Shuffle. The current version of GTKPod (0.87) does not support the Shuffle, but chances are it will by the time you read this.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

i have an old ipod,

Anonymous's picture

i have an old ipod, formatted for mac & when i try to use the program it can't transfer any files to the ipod, and it gives me a "read-only" system error message any tips? i've tried restoring it on a mac & using other methods like transfering them on rythynmbox via the menus and such, the wierd thing is i can bring files over from the ipod but not vice-a-versa.


John Turner's picture

This is the best information I have found for a newbie like me on the web. Keep up the good work!

What about Ogg Vorbis files?

Anonymous's picture

Will this work for Ogg files? Could you guys write a follow-up OGG article?

I would rather use Ogg on my iPod than proprietary mp3.


If you want to play Ogg

Anonymous's picture

If you want to play Ogg Vorbis on an iPod you may find Rockbox of interest:

disconnecting the Ipod

Tom's picture

In the LJ article, Bert alluded to problems getting rid of the
do not disconnect message on the Ipod. I'm using
SuSE Professional 9.3, Ipod mini software version 1.4 and connecting
via USB. I found that if I exit gtkpod and then type eject
that the disconnect message dissappears, and the Ipod
displays its standard menu.

My solution, on Ubuntu, was

Anonymous's picture

My solution, on Ubuntu, was to open the terminal and type:

sudo eject sda2

The first time I did it, the Do Not Disconnect screen remained, but I disconnected anyway because I was sick and tired of the nonsense. Subsequent times it really did eject the iPod.

eject sda2 works.

thelenshar's picture

This works for me as well:
'eject sda2'

That did not work first time i tried it, so i tried other aproaches, like unloading the usb modules, which didn't work, cos then my mouse wouldn't work (its usb, and even though i could have used ps2, ps2 port was broken, but thats another solution if you don't have anything else on USB)

Make sure you have permission

CyberInferno's picture

I found the same problem. I didn't have permission to eject sda (I eject sda and it removes sda1 and sda2 as well). I'm using PCLinuxOS which runs on KDE. When I used su and ejected the device, it worked fine. So I went into my user account privileges and added my account to the group "disk". After I logged out and logged back in, I was able to eject it without any problems or the need of a super user account. I use Amarok and have the device set to use "eject /dev/sda" as my unmount command and it works fine when I eject it. Good luck!

'eject /dev/sda' (or

Anonymous's picture

'eject /dev/sda' (or possibly 'eject sda') should work. Just 'eject /media/ipod' or 'eject /dev/sda2' did not work for me (FC4).

Charging Ipod Shuffle

thomaslai's picture

Did u manage to charge Ipod Shuffle from Ubuntu using USB 2.0 ports? Mine can't seem to work.

Uhm, i could charge the ipod

thelenshar's picture

Uhm, i could charge the ipod video. i don't have a shuffle, so i can't test it.. i am pretty sure other people have gotten it to work, so yea, uhm, wanna explain more details?

My Ipod shuffle charges on a

Anonymous's picture

My Ipod shuffle charges on a USB 2.0 port. I've tried both the 1 Gig (I bought that) and 512MB (free from bankone). Make sure you format it FAT32 via a windoze machine

You don't need windows to

synorgy's picture

You don't need windows to format an iPod. Install gParted, plug in your iPod and fire up gParted. It will open and (once you change the device) allow you to format your iPod (or your harddrive if you aren't careful)

Unfortunately gparted is far

rguinn's picture

Unfortunately gparted is far more adept at crashing than formatting anything.


Anurag's picture

You can use fdisk instead, a command line utility

Thanks for the post! But my

in confusion's picture

Thanks for the post! But my ipod is out of