Author: Joe Barr
Finally, an important note: All commands in this article are as they would be entered on my machine. Your system may require you to use different devices, mount points, and directories. DO NOT SIMPLY COPY AND PASTE THESE COMMANDS TO EXECUTE THEM ON YOUR MACHINE.
Housekeeping
Before we get started on the Nano, let’s do a little preparation on the Linux machine we’ll be installing from. To keep things tidy during the installation, I went into superuser mode for the duration of the install and created a directory for the purpose with the command
.
# mkdir iplinstall
Next, I visited the iPodLinux Project site and downloaded a kernel and podzilla, the user interface for iPodLinux, from the nightly builds. I also downloaded the iPod Boot Loader and an iPod Linux Userland from the project page on SourceForge, placing both items in my newly created iplinstall directory. The iPod Boot Loader is needed to install and boot iPodLinux on the Nano, and the iPod Linux Userland provides a Linux file hierarchy populated with all the executables needed to run iPodLinux.
I decompressed the nightly kernel and podzilla downloads, but left the filesystem tarball alone. We’ll decompress that later after we get the iPod ready for it. Next, I made a backup of the existing master boot record (MBR) and boot partition on the iPod. After booting the iPod into disk mode, I connected the USB cable to the iPod and the PC. There is no guarantee that the iPod is going to show up as the same device (/dev/sda, /dev/sdb, /dev/sdc) each time, so always check and see where it is each time it is mounted. Do that with a naked mount command, like this:
# mount /dev/hda1 on / type ext3 (rw,errors=remount-ro) proc on /proc type proc (rw) /sys on /sys type sysfs (rw) varrun on /var/run type tmpfs (rw) varlock on /var/lock type tmpfs (rw) udev on /dev type tmpfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) devshm on /dev/shm type tmpfs (rw) /dev/sda1 on /backup type ext2 (rw) /dev/hdb1 on /home type ext3 (rw) tmpfs on /lib/modules/2.6.15-19-386/volatile type tmpfs (rw,mode=0755) /dev/sdb2 on /media/ipod type vfat (rw,nosuid,nodev,quiet,shortname=mixed,uid=1000,gid=1000,umask=077,iocharset=utf8)
As you can see, this time it showed up as /dev/sdb2 and Ubuntu mounted it as /media/ipod. Your mount type may vary, as distributions choose their own paths for these things.
Making a copy of the MBR and the boot partition is as easy as entering the following two commands:
# dd if=/dev/sdb of=ipod_boot_sector_backup bs=512 count=1 # dd if=/dev/sdb1 of=ipod_os_partition_backup
Checkpoint, Charlie?
Let’s check to make sure we have everything we need before proceeding. A directory listing in your install directory should look similar to this:
# ls -al total 84364 drwxr-xr-x 2 warthawg warthawg 4096 2006-03-23 14:08 . drwxr-xr-x 57 warthawg warthawg 4096 2006-03-23 13:51 .. -rw-r--r-- 1 warthawg warthawg 1650596 2006-03-23 13:14 2006-03-22-kernel.bin -rw-r--r-- 1 warthawg warthawg 821824 2006-03-23 13:14 2006-03-22-podzilla -rw-r--r-- 1 root root 512 2006-03-23 14:07 ipod_boot_sector_backup -rw-r--r-- 1 warthawg warthawg 1578270 2006-03-23 13:17 ipod_fs_240206.tar.gz -rw-r--r-- 1 root root 82220544 2006-03-23 14:08 ipod_os_partition_backup
We have a kernel, podzilla, filesystem, and the two iPod backup files. Everything is in place.
Repartitioning the Nano
Straight from the factory, the Nano comes with two partitions — one of 10 cylinders and the second 114 cylinders. If your Nano is still mounted, use umount
to unmount it. On my system, the command is:
umount /media/ipod
Now start fdisk to see what’s there, using the p
command to display the existing partition table:
# fdisk /dev/sdbCommand (m for help): p
Disk /dev/sdb: 1023 MB, 1023933952 bytes 255 heads, 63 sectors/track, 124 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdb1 1 10 80293+ 0 Empty /dev/sdb2 11 124 915705 b W95 FAT32
Just as expected. Delete the second partition using the d
command and specifying partition 2 when asked. That done, we’ll recreate it a few cylinders smaller than it was originally. Here’s the fdisk dialog from my machine when I recreated the partition:
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (1-124, default 1): 11 Last cylinder or +size or +sizeM or +sizeK (11-124, default 124): 104Command (m for help): p
Disk /dev/sdb: 1023 MB, 1023933952 bytes 255 heads, 63 sectors/track, 124 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdb1 1 10 80293+ 0 Empty /dev/sdb2 11 104 755055 83 Linux
Be careful that you don’t overlap the first partition with the second, because fdisk is not smart enough to keep you from doing so, or even to suggest a decent default starting location. Make the starting cylinder for the second partition 1 greater than the end of the first partition. As shown above, the first partition ends in cylinder 10, and the second begins in 11, just as it did originally. But now the end point is 104 instead of 124, which gives us plenty of space for our new Linux partition.
Before we make the Linux partition, let’s do two more things: change the type of the second partition to FAT, and make both the first and the second partitions bootable. To change the type, use fdisk’s t
command, specify partition 2, and enter b
for the new type. To make both partitions bootable, use the a
command, specify 1, and then repeat for partition 2. Now the partition table should look like this:
Command (m for help): pDisk /dev/sdb: 1023 MB, 1023933952 bytes 255 heads, 63 sectors/track, 124 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdb1 * 1 10 80293+ 0 Empty /dev/sdb2 * 11 104 755055 b W95 FAT32
If your partition table looks like the one above, you’re ready to proceed. If not, repeat the deletion and creation of the second partition, changing the type to FAT, and making both partitions bootable.
n command, p
for primary partition, and 3
for the partition number. The starting cylinder will be 105, and you can accept the default ending location of 124. When you’ve finished, it should look like this:
Command (m for help): pDisk /dev/sdb: 1023 MB, 1023933952 bytes 255 heads, 63 sectors/track, 124 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdb1 * 1 10 80293+ 0 Empty /dev/sdb2 * 11 104 755055 b W95 FAT32 /dev/sdb3 105 124 160650 83 Linux
Double check that you haven’t overlaid the previous partition, and if all looks right write the new partition table to disk using the w
command. fdisk will end automatically when the write completes. Now you can unmount and eject the Nano:
# umount /media/ipod # eject /dev/sdb
Doing so should cause the iPod to reboot, and it will be remounted when it does. Remember to double check that it is mounted and to verify which device it is.
As you can see from the output of the mount command on my system, I now have two partitions showing up on /dev/sdb: sdb2 is the FAT partition and SDB3 is the Linux (ext2) partition:
# mount /dev/hda1 on / type ext3 (rw,errors=remount-ro) proc on /proc type proc (rw) /sys on /sys type sysfs (rw) varrun on /var/run type tmpfs (rw) varlock on /var/lock type tmpfs (rw) udev on /dev type tmpfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) devshm on /dev/shm type tmpfs (rw) /dev/sda1 on /backup type ext2 (rw) /dev/hdb1 on /home type ext3 (rw) tmpfs on /lib/modules/2.6.15-19-386/volatile type tmpfs (rw,mode=0755) /dev/sdb3 on /media/ipod type ext2 (rw,nosuid,nodev) /dev/sdb2 on /media/ipod-1 type vfat (rw,nosuid,nodev,quiet,shortname=mixed,uid=1000,gid=1000,umask=077,iocharset=utf8)
Now let’s create the filesystems for those partitions. Unmount sdb2 and create the FAT file system on it:
# umount /media/ipod-1 # mkdosfs -F 32 /dev/sdb2
Then unmount sdb3 and create the ext2 file system on it:
# umount /media/ipod # mke2fs /dev/sdb3
And finally, turn off the autochecking on the Linux partition:
# tune2fs -c 0 /dev/sdb3 tune2fs 1.38 (30-Jun-2005) Setting maximal mount count to -1
Our partitioning chores are done.
Create and install the new root image
Now we’re going to create a new root image that will load Linux by default, or the Apple OS originally installed if you hold down REVERSE while booting. We already downloaded the iPod Boot Loader from the project Web site and placed it in our installation directory. Untar and decompress it by entering:
# tar xzf Ipodloader-20060114.tar.gz
Now enter the new subdirectory just created by tar and copy two of the files up into the parent directory, and return to the install directory:
# cd iploader-20060114 # cp loader.bin ../ # cp make_fw ../ # cd ..
Back in the friendly confines of our install directory, we can now extract the Apple OS from the backup of the root partition we made earlier. Enter the following command:
# ./make_fw -o apple_os.bin -e 0 ipod_os_partition_backup
The next step requires we have the Apple binary (just created), the Linux binary (downloaded earlier), and the loader binary, just copied into the install directory. With those three pieces of the puzzle all present and accounted for, we can create our new image:
# ./make_fw -g nano -o my_sw.bin -l 2006-03-22-kernel.bin -i apple_os.bin loader.bin Generating firmware image compatible with iPod mini, 4g and iPod photo...
Copy the new image to the Nano using dd
:
# dd if=my_sw.bin of=/dev/sdb1 13180+1 records in 13180+1 records out 6748508 bytes (6.7 MB) copied, 0.802989 seconds, 8.4 MB/s
Check to make sure the Linux partition is mounted, and if not, mount it:
mount -t ext2 /dev/sdb3 /media/ipod
Now go into that partition and lay down the file system we downloaded earlier:
# cd /media/ipod root@desktop:/media/ipod# tar zxpf /home/warthawg/iplinstall/ipod_fs_240206.tar.gz tar: dev: implausibly old time stamp 1903-12-31 18:00:00 tar: home: implausibly old time stamp 1903-12-31 18:00:00 tar: lib/modules/2.4.20-uc0/kernel/drivers/ieee1394: implausibly old time stamp 1903-12-31 18:00:00 tar: lib/modules/2.4.20-uc0/kernel/drivers: implausibly old time stamp 1903-12-31 18:00:00 tar: lib/modules/2.4.20-uc0/kernel: implausibly old time stamp 1903-12-31 18:00:00 tar: lib/modules/2.4.20-uc0/pcmcia: implausibly old time stamp 1903-12-31 18:00:00 tar: lib/modules/2.4.20-uc0: implausibly old time stamp 1903-12-31 18:00:00 tar: lib/modules: implausibly old time stamp 1903-12-31 18:00:00 tar: lib: implausibly old time stamp 1903-12-31 18:00:00 tar: mnt: implausibly old time stamp 1903-12-31 18:00:00 tar: proc: implausibly old time stamp 1903-12-31 18:00:00 tar: var/log: implausibly old time stamp 1903-12-31 18:00:00 tar: var/run: implausibly old time stamp 1903-12-31 18:00:00 tar: var/tmp: implausibly old time stamp 1903-12-31 18:00:00 tar: var/lock: implausibly old time stamp 1903-12-31 18:00:00 tar: var: implausibly old time stamp 1903-12-31 18:00:00
One more thing to do while we are in the Linux partition. Let’s replace the version of podzilla that came in the file system download with the latest build we downloaded earlier and make it executable:
# cd /media/ipod/bin # mv podzilla podzilla.old # cp ~/iplinstall/2006-03-22-podzilla podzilla # chmod +x podzilla
Now we need to get out of Dodge — well, out of the Linux partition, at least — and unmount the partition and eject the Nano:
# cd ~/iplinstall # umount /media/ipod # eject /dev/sdb
Disconnect your Nano from the USB and reboot it. If all has gone correctly, it should go directly into Linux and run podzilla when you do so. To boot into Apple OS instead, hold down REVERSE while booting.
Now you can impress your friends at a LUG meeting, as I did last night, because you are the proud owner of a dual-booting Nano.