[philiptellis] /bb|[^b]{2}/
Never stop Grokking

Friday, May 13, 2005

Using your iPod through FreeBSD

If you're a die hard linux or FreeBSD fan, or are just a geek and happen to have an iPod, then you have an opportunity to play. Getting your iPod to work with FreeBSD or linux can bring you much glee. Unfortunately for you, I'm going to shatter your hopes and tell you how to do it.

This howto is about FreeBSD 4.10 and a USB iPod shuffle, because that's what I have. Other kinds of iPods will also work without change in the procedure. If you have an older FreeBSD, it may or may not work this way, if you have a newer FreeBSD, it will work better.

Linux should be far simpler, and there are already instructions on the net, so I won't cover that.

So, to start with, you've got to make sure your kernel supports a few things.
- usb (if you have a USB iPod, but put it in anyway)
- ohci/uhci/ehci (the first two for USB 1.x, depending on the type you have, the latter for USB 2.x, put all three in, it won't cause problems)
- firewire (if you have a firewire iPod)
- sbp (serial bus protocol)
- scbus, da, cd, pass
- umass (mass usb storage)
- msdos file system support

To do this, edit your kernel config file, which should be in /usr/src/sys/i386/conf/KERNELNAME or something like that. uname -a will tell you for sure.

Add the following to the end of the file:

# For the iPod
options MSDOSFS
device sbp
device firewire
device scbus
device da
device cd
device pass
device uhci
device ohci
device ehci
device usb
device umass

Of course, check in advance that these aren't already in the file.

Once that's done, reconfigure and rebuild your kernel:

cd ../../compile/KERNELNAME
make depend
make install

Also tell your system to load msdos file system at boot up. In /boot/loader.conf, add this:

Next, install gtkpod. You can portinstall it. Get version 0.88 at least if you need support for the iPod shuffle.

Now, plug in your iPod. The USB iPod should throw some messages into dmesg saying that the Apple iPod is loaded on bus:0, target:0 and lun:0 (or something else). Take note of these numbers.

Now, you can mount the drive as msdos. It should be attached to /dev/da0s1 or something like that. You'll know for sure from the dmesg messages. Run dmesg, and note whether the iPod is on da0 or da1 or something else. That's the drive your iPod is attached to. It will always be s1, ie, the first BIOS partition, known in FreeBSD as slice 1. On linux it could be as simple as /dev/sda1

Create a mount point for the drive:

mkdir /mnt/ipod

Mount the drive with the msdos filesystem - assuming this is a windows formatted iPod. If you have a mac formatted iPod, you'll have to do one of the following:
- Add HFS support to your kernel (4.10 may not have this support), or
- Reformat it as a windows iPod using windows, mac or pc-fdisk on FreeBSD/Linux. I wasn't very successful running pc-fdisk on the drive in FreeBSD, but that's prolly because of a bad USB implementation in 4.10

You'll find instructions about formatting at the gtkpod site.

To mount use this:

mount -t msdos /dev/da0s1 /mnt/ipod

Now run gtkpod, and follow its interface.

Once you're done with gtkpod, quit, and unmount the drive. The orange light might still blink, indicating that the drive is not ready to be removed. Use camcontrol to eject it:

camcontrol eject 0:0:0

The numbers at the end are your bus:target:lun numbers, so use the ones you noted down at the start.

Once you've done that you should be able to unplug the iPod and use it.

That's it. Have fun.