Ipodlinux:basic

Throughout the document we use %1 to represent the kernel version and %2 to represent the patch version. We assume that you downloaded all the files from "Getting the required files" into ~/ipod (~ stands for your home directory, e.g. /home/flonejek/, so ~/ipod would be /home/flonejek/ipod)

If you have a Mac Ipod you can skip the Partitioning step. Also swap '/mnt/ipod' for '/Volumes/ipod'
 * Mac iPod Notice

Backing Up Your Ipod's Firmware and Bootloader
The iPod "firmware" is a complex beast that actually consists of some code stored on flash ROM as well as code stored on the hard drive. A complete discussion of the boot process may be found here in the near future, but for the moment we shall say that the hard drive contains the operating system and bootloader which is loaded into the flash rom upon boot. We are going to replace the firmware (OS and bootloader), and thus need to make a backup of that code.

The hard drive in the iPod is partitioned by default into two partitions. Normally these will be visible under Linux as /dev/sda1 and /dev/sda2. If you are currently using Linux tools to manage your music (i.e. gtkpod) you would be familiar with the second partition as it is a FAT32 formatted partition and contains your music.

Once you can successfully access your iPod from Linux (for example mount -t msdos /dev/sda2 /mnt/iPod) you can make a backup of your iPod OS partition.


 * 1) dd if=/dev/sda1 of=ipodfirmware
 * 2) dd if=/dev/sda  of=ipodbootloader bs=512 count=1

This will make a complete copy of the /dev/sda1 partition and save it to the file ipodfirmware, as well as saving the master boot record too ipodbootloader. You can modify the parameters to suite your local setup.

To restore this data to your iPod you would simply switch the if and of arguments. That is:


 * 1) dd if=ipodfirmware of=/dev/sda1
 * 2) dd if=ipodbootloader  of=/dev/sda bs=512 count=1

Note, in order to do this you need to have your iPod in "diskmode". This is because its risky to write to the partition while the os is running, but in diskmode, the os isn't running, making for a safer restore. In order to boot in "diskmode" you need to reset the iPod by holding down the menu and play/pause buttons for 10 seconds and then when the Apple icon appears hold down the fast forward and rewind buttons until the "OK to disconnect" message appears.

In this forced diskmode removing the firewire cable does not cause the iPod to reboot as it would normally. Again you need to reset by holding down the fast forward and rewind buttons. If you have reverted to the Apple firmware it should start shortly after the Apple icon appears.

Partition Your Ipod
The number of cylinders for this disk is set to 2431. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): Delete Firmware Partition Command (m for help): d Partition number (1-4): 1 Create a new primary partition with a length of 1 cylinder. Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-2431, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-5, default 5): 1 Command (m for help): a Partition number (1-4): 1 Set partition type to 'Empty' Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): 0 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (1-2431, default 1): 2 Last cylinder or +size or +sizeM or +sizeK (1-5, default 5): 5 Command (m for help): p Disk /dev/sda: 20.0 GB, 20000268288 bytes 255 heads, 63 sectors/track, 2431 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot   Start       End    Blocks   Id  System /dev/sda1  *         1         1      8001    0  Empty /dev/sda2  *         6      2431  19486845    b  Win95 FAT32 /dev/sda3            2         5     32130   83  Linux Partition table entries are not in disk order Command (m for help): w fdisk will now exit and we can create the new filesystem. tune2fs 1.34 (25-Jul-2003) Setting maximal mount count to -1
 * 1) umount /dev/sda2
 * Start fdisk
 * 1) fdisk /dev/sda
 * Activate the first partition.
 * Create the 3rd primary partition from 2nd to 5th Cylinder (this is around 30 megs in size)
 * Review the changes. Note, this is for a 20GB verison, the sda2 parition size will vary.
 * If everything looks ok, write out the partition table.
 * 1) mke2fs -j /dev/sda3
 * If you don't want your ipod to run disk checks at boot, set the maximal mount count to never.
 * 1) tune2fs -c 0 /dev/sda3

Use the make_fw tool from the iPod Boot Loader to extract and patch the Apple firmware
Extract the bootloader mac ipod owners do command below instead of the command above Extract firmware from backup Extract the precompiled kernel Patch firmware and
 * 1) cd ~/ipod
 * 1) tar -xvzf ipodloader-version.tar.gz
 * 1) tar -xvzf ipodloader-mac-ppc-version.tar.gz
 * 2) cd ipodloader-version
 * 1) make_fw -o ../apple_fw.bin -e 0 ../ipodfirmware
 * 1) tar -xvzf uclinux-%1-ipod%2.tar.gz
 * 1) make_fw -o ../my_fw.bin -i ../apple_fw.bin -l ../uclinux-%1-ipod%2/uclinux-%1-ipod%2.bin loader.bin

Copy over bootloader, boot images, and kernel modules
Copy the patched firmware/bootloader back to the ipod Copy the kernel modules to the ipod root filesystem
 * 1) cd ~/ipod
 * 2) dd if=my_fw.bin of=/dev/sda1
 * 1) umount /mnt/ipod (just in case)
 * 2) mount -t ext3 /dev/sda3 /mnt/ipod
 * 3) cp -r /uclinux-%1-ipod%2/lib /mnt/ipod

Copy over Root Filesystem
Change to the iPods directory Extract the root filesystem onto the ipods root directory
 * 1) cd /mnt/ipod
 * 1) tar -xvzf ipod_fs_version.tar.gz

Unmount, eject, and reboot your ipod
unmount ipod eject ipod Reboot your ipod by holding down the play and pause buttons together. To boot into linux hold down the rewind button when you see the apple, otherwise ipod will default boot into its native os. All of your files should be there, all the partitioning we did was only on the boot partition.
 * 1) umount /mnt/ipod
 * 1) eject /dev/sda

Note for Windows iPods
To see your music files on /dev/hda3 (windows ipod fat32 bit) you need to mount the partition to make it visible to the file browser. Then you just navigate with the file browser to the directory and select with the action menu. The screen will then switch back to a console view and the mp3 will play. You can use the pause/play button to pause and restart playback or the menu to quit play back. When the playback stops you will return to podzilla.

For win-ipods you need to add an extra command to the etc/rc file on your iPod.

(-o=option, ro=read only, -t=type, vfat=fat32 filesystem)
 * 1) mount -o ro -t vfat /dev/hda2 /mnt

To do this, connect your iPod to the PC/Mac and mount it as an external drive. Then use a text editor on the /etc/rc file and add the above command somewhere directly before the hdparm line.

The few lines look like:

modprobe eth1394 ifconfig eth0 192.168.222.2 mtu 170 mount -o ro -t vfat /dev/hda2 /mnt hdparm -S 3 /dev/hda << mount commands have to be before this line podzilla << This command starts podzilla straight after you boot

For mac-ipods the music is on your root (/dev/hda3) partition and so you don't need this extra mount command.

The directory /mnt/iPod_Control/Music (or just /iPod_Control/Music for mac ipods) then contains a set of directories like f00, f01, f02... These directories contain the actual mp3s with slightly strange filenames.

To restart podzilla (upon accidental exit)

 * 1) Edit the etc/rc file and remove the podzilla command from the last line.
 * 2) Edit the etc/inittab and add the following line.

pz:pz:/sbin/podzilla

Now if you exit podzilla it will just restart.