A while ago I had to replace my (5.5th gen) iPod's hard drive and was disgusted when I realized that I had to use iTunes for that. So when I had a bit of spare time I set out to try and find a way to do so without using iTunes (or any other non-free software). In case anyone cares, here's how I did it:
Basically, we need four (4) things:
- Linux (full install, VM, or live CD)
- A partition table
- Firmware (Rockbox) on the first partition
- Music on the second partition (or just Doom)
I'll assume that the storage media (hard drive, sd card or whatever) is installed in the iPod and the iPod is connected to the PC via USB (in "disk mode", hold SELECT and PLAY which powering up). I'll be using /dev/sdX for all examples, that way you shouldn't break anything if you just lazily copy & paste my commands.
I'll also assume that you've already compiled Rockbox and all its tools (including
ipodpatcher and
ipod_fw).
The partition tableThis part is fairly straight-forward: we need two partitions. One for the firmware images, and one for the music. Rockbox supports
several ways to be installed on the iPod. Since I don't care about other OS' and I don't mind a little extra work when updating Rockbox, I chose the "OSOS contains only Rockbox" way, i.e. the firmware partition only contains the Rockbox image. Also, it boots faster than all the other methods, so that's a good thing.
That said, my
rockbox.bin image is about 800 kB so I'll create a 2 MB partition for it (that way we are safe even if future Rockbox images get a little larger -- compared to the 80 MB that Apple uses for this partition we are still pretty efficient).
Here's where things get a little hairy: I have two "identical" 5.5th gen iPods (same model number etc.) but they use different sector sizes on the disk. One uses 512 Bytes per sector, the other one uses 2048 Bytes. The partition table differs slightly so we should know which model we are dealing with.
Luckily, Rockbox has a tool for that. Use
ipodpatcher -l
and you will get something like this for the
512 Bytes model:
[INFO] Scanning disk devices...
[INFO] Read XML info (9692 bytes)
[INFO] Ipod found - Photo/Color ("winpod") - /dev/sdc
[INFO] Reading partition table from /dev/sdc
[INFO] Sector size is 512 bytes
Or, for the one with
2048 bytes:
[INFO] Sector size is 2048 bytes
So now we can create our partition table. They are almost identical for both models, except that one the
512 Bytes model, we need 4096 sectors for our 2 MB partition (4096 * 512 B = 2 KB) whereas the
2048 Bytes iPod only needs 1024 sectors (1024 * 2048 Bytes = 2 MB).
Thus we get the following partition table for the
512 Bytes model
label: dos
unit: sectors
start=63, size=4096, type=0
start=4159, type=b
Or, for the one with
2048 Bytes:
label: dos
unit: sectors
start=63, size=1024, type=0
start=1087, type=b
Copy these instruction to a file (eg. /tmp/ipod.script) and load it:
sfdisk /dev/sdX < /tmp/ipod.script
Confirm that the partition table has successfully been adjusted using
fdisk -l /dev/sdX
FirmwareNow for the tricky part. In theory it's quite simple: just put the rockbox binary in the first partition and that's it. Unfortunately, the 5.5th gen iPod needs a
second firmware image, too. Luckily, Rockbox knows how to generate that one, too, and we can use it. Unfortunately, we need two different tools and little bit of glue to generate the full image for our firmware partition.
Anyway, this is what we do: first we use
scramble to generate an image for us. The image that it generates won't work on our iPod, but it
does contain the aforementioned second image that we need. This is how we generate the image:
../tools/scramble -ipod5g rockbox.bin temp.img
The image is a little bit too short, so we'll need to append a few zeros to it:
dd if=/dev/zero of=temp.img oflag=append conv=notrunc bs=1024 count=1
Now we can extract the second image:
../tools/ipod_fw -o apple_sw_5g_rcsc.bin -e 1 temp.img
The name of the image ("apple_sw_5g_rcsc.bin") is a bit silly but it's hard-coded in another tool so we'll just use that.
Now that we have both images required for the iPod to boot (
rockbox.bin and
apple_sw_5g_rcsc.bin), we can use the
ipod_fw tool to generate a firmware image from them. This step again depends on the iPod's sector size.
For iPods with
512 Bytes per sector, we use:
../tools/ipod_fw -g 5g -o firmware.bin -l rockbox.bin -n -r 0xb000
Or, with
2048 Bytes per sector:
../tools/ipod_fw -s 2048 -g 5g -o firmware.bin -l rockbox.bin -n -r 0xb000
Now we can write the image to the iPod:
dd if=firmware.bin of=/dev/sdX1 bs=512
And that's pretty much it. The iPod is almost ready now.
Data partitionI'm not sure whether this is really needed, but I suppose it can't hurt: When creating the file system for the data partition, we can again specify the size of our sectors. For
512 Bytes, use:
mkfs.vfat -F 32 /dev/sdX2
Or, for
2048 Bytes:
mkfs.vfat -F 32 /dev/sdX2 -S 2048
Then don't forget to add the Rockbox data files:
mount /dev/sdX2 /mnt/ipod
tar --no-same-owner -C /mnt/ipod/ -xf rockbox.tar
umount /mnt/ipod
Et voilà, your iPod should be ready.