Installing Debian on a Apple iBook2 (mid-2002)


by Mike Johnson, mike (at) publicstatic.net

Last updated 2/7/2003

Introduction

This installation will much more interesting install than most people will ever attempt. There are a lot of little things to do, but there's nothing in this guide that's too difficult. If you need more help installing Debian, feel free to send me an email at mike (at) publicstatic.net. For those who won't be installing Debian, using maybe some other distribution, any problem you're likely to encounter has already fixed by successive Debian users and their trials have been dutifully logged. Hopefully this guide can assist your installation.

I should note that I'm not associated with the Debian project and these are my personal experiences with Debian.

Why Linux and not OSX?

While OSX certainly has it's highlights, on a practical level I believe any schooled Unix user will be pretty uncomfortable. Many important applications only run in the rootless X server, which may look cool but it's slow to load. OpenOffice, for example, is currently unavailable in an Aqua version and many other frustrations.

These are practical problems and I'm sure somebody will address these, but more importantly OSX is still a closed-source OS. Sure, they've made progress by open-sourcing Darwin and Rendezvous, but Aqua and many other pieces are still closed and I'm sure they always will be. It's not software that you can share with your friends or software who's source code you can inspect. It's an issue of freedom, and OSX is just not open enough when the novelty of postscript interfaces wears off.

On the other hand, the hardware is great. It's one of the best computers I've ever used. OpenFirmware is interesting, nothing like the decades-old bios on Intel compatibles, and the battery literally lasts ages. I bought a second battery with my laptop not knowing it would be completely unnecessary. My iBook is fast, capable, the thing goes to sleep in seconds flat, and running Linux is a huge performance increase. It's a great platform.

Booting the Install Image

Firstly, follow the fine directions over at debian.org, which I'll briefly summarize here. Grab the files linux, yaboot, yaboo.conf and images-1.44/root.bin from your favorite ppc mirror. It's important to save these to the root of your hard drive. You can use the finder to do this.

Reboot your Macintosh and press (and hold) command-option-o-f after the chime. This will drop you into the Open Firmware terminal. To tell the firmware we'd like to boot, simply enter "boot hd:9,yaboot". The drive partition (the 9) for the yaboot image may vary depending on your configuration. There's no danger in trying other numbers until yaboot loads if nine is incorrect for your system.

Booting Linux

The next thing to load should be the yaboot bootloader. If you press tab you can get a list of kernels to load. Most distributions offer a text mode installation, Debian unfortunately does not and the framebuffering used by the kernel white-washed my screen. If you have an ATI Radeon Mobility M6 or have problems, enter "Linux video=ofonly" at the yaboot prompt.

Partitioning your drive

After booting into the installer, things should generally look like any other x86 installation you've done. Partitioning the drive is about the most action we'll get. It should look like this:


Command (? for help):


If you hit 'p', fdisk will print a list of your current structure. If you'll be installing Linux along a OSX install, you should already have some empty space on a drive you can setup Debian on. Otherwise go ahead and hit 'i' to clear your drive. fdisk will prompt you to confirm and then to double-check the block-size of your drive. If you're using an older version of mac-fdisk, the block-size is likely to be wrong. You should be able to add the partitions from the above printout together, starting at the base value. Otherwise, just hit enter.

Next you'll need an 800k partition for yaboot. Press 'b' and hit enter to allow fdisk to do this automagically. With older fdisk versions, you should hit 'C' and create a partition like this:


/dev/hda2         Apple_Bootstrap boot                   1600 @ 64       (800.0k)  NewWorld bootblock


Next use 'c' to create a swap partition:


Command (? for help): p

/dev/hda

        #                    type name                 length   base     ( size )  system

dump: name /dev/hda len 8

/dev/hda1     Apple_partition_map Apple                    63 @ 1        ( 31.5k)  Partition map

/dev/hda2         Apple_Bootstrap boot                   1600 @ 64       (800.0k)  NewWorld bootblock


Block size=512, Number of Blocks=58605120

DeviceType=0x0, DeviceId=0x0


Command (? for help): c

First block: 1664

Length (in blocks, kB (k), MB (M) or GB (G)): 500M

Name of partition: swap


Make sure you call it "swap" or the installer will complain. Next you'll need a root partition, simply follow the same procedure. Likewise, the partition name must be "root."

Keyboards

Older Debian installers, and possibly other distributions, occasionally guess your computer has an old "ADB" keyboard. If after the installation you have keyboard problems, try adding "keyboard_sends_linux_keycodes=1" to the boot command. You'll also need the "ikeyd" packages to use the laptop's function keys, like F12 for ejecting the CDROM.

The one button mouse is a frustration at times, but you can make the F10 and F11 keys act like the middle- and right-button mouse clicks by running as root:


echo "1" > /proc/sys/dev/mac_hid/mouse_button_emulation

echo "68" > /proc/sys/dev/mac_hid/mouse_button2_keycode

echo "87" > /proc/sys/dev/mac_hid/mouse_button3_keycode


Thanks to Edd Dumbill for pointing this out.


Also, while running under X, you can modify the Apple key to work as the alt modifier. The real alt key is much smaller on the iBook than on most US-style keyboards and I'm constantly missing it, usually in emacs. Note that this tip will not work on the console, just in X. Nor will it work if you're using XKB (this is not most people).

You can use `xev` to determine which keycode your Apple key is sending, but these values here worked for me. First, run these commands:


xmodmap -e 'keycode 115 = Alt_L'

xmodmap -e 'add mod1 = Alt_L'


Assuming your Apple key is now working as alt, you can make these changes permanent by creating the file /etc/X11/Xmodmap as root and pasting these values:

keycode 115 = Alt_L

add mod1 = Alt_L

Getting X11 to Work

Apple is constantly changing their video cards, so your card may not have supplied modules or X11 drivers yet, especially if you stay with the Debian stable tree. Compiling and installing XFree is fortunately not very difficult, you can follow the directions on their site to get the latest release. I found at least 4.2 is required for the Radeon Mobility M6, but your mileage may vary. For certain cards, you may be able to find help over at the Gatos project.

You'll want to move /usr/X11R6 out of the way before you run `make install`, it always pays to keep a backup around. If you have programs installed there, it's easiest to use `apt-get --reinstall install <package>` to restore the files.

Here's the configuration file for my laptop. You'll probably want to upgrade your kernel while your at it, like described in the next section. This also helped solve some video corruption problems during wake.

Upgrading the Kernel

You can compile your own if you like, or simply download and use the latest BenH kernel from http://www.ppckernel.org/kernel.php?id=21. Props to Ben for the help!

Sleep, Power Management

The power management is a snap, as long as you have PMU support built into your kernel. PMU is controlled by a devicefile /dev/pmu, it should have these major and minor numbers:


crw-------    1 root     root      10, 154 Sep 24 15:00 /dev/pmu


After that, you'll need the "pmud" and "pmud-utils" packages on your system. With pmud running, closing your laptop's lid should put it to sleep (you can also run the "snooze" command manually), replete with the glowing sleep light.

You can change the hard drive spin down times with "hdparm," which is also not installed by default. Otherwise you can use /etc/power/pwrctl-local to control the options. Just don't forget to make the -local file executable, or it will not be read.

There are also some handy tips here that'll help you to extend your battery's life. In general, running fewer daemons and turning down the display brightness will help (use `fblevel 8` to manually dim the screen). You can also install the xpmumon utility to check how much you're pulling.

Sound

First run these commands as root to verify you have the correct modules for your kernel installed:


modprobe soundcore dmasound_core dmasound_pmac

modprobe dmasound_core dmasound_pmac

modprobe dmasound_pmac


If any of these are unsuccessful, you'll need to upgrade your kernel. I strongly recommend using the BenH kernels (see above section) but I'll also be making a guide and a configuration file for the 2.4 series. Assuming your configuration is okay, fire up XMMS and check your sound -- it should work just fine. Next create a the file /etc/modultils/sound and drop these lines in:


alias char-major-14 soundcore

alias sound-slot-0 dmasound_pmac

alias char-major-14-3 dmasound_pmac

alias /dev/dsp dmasound_pmac

alias sound-service-0-0 i2c-keywest

alias char-major-14-0 i2c-keywest

alias /dev/mixer i2c-keywest


These lines will ensure your audio works the next time you boot. Just run `/sbin/update-modules` to rebuild the /etc/modules.conf file. Piece of cake thanks to the tips from Evan Martin.

Drive Speed

Hard drives are always the slowest thing about a computer, especially a laptop, so here are a few tips to speed it up. By default, most systems will record the time on every file access on your hard drive. Thus with each read there is another write to update the last accessed bit, you can turn this off in /etc/fstab. Add the "noatime" option like this:


/dev/hda4    /    ext3    errors=remount-ro,noatime    0 1


Changing the file doesn't activate that change, so run `mount -o remount /` to remount your root volume. You'll also want to turn on 32 bit access and DMA for your drive:


ibook:~# hdparm -c 1 /dev/hda

/dev/hda:

setting 32-bit IO_support flag to 1

IO_support = 1 (32-bit)

ibook:~# hdparm -d 1 /dev/hda

/dev/hda:

setting using_dma to 1 (on)

using_dma = 1 (on)


This is going to get reset with every reboot, so make sure to add this in an rc script like /etc/init.d/bootmisc.sh.

Java

You can pickup a full SDK from the Blackdown project. Follow the same procedure you'd do elsewhere, just make sure to set the JAVA_HOME environment variable to where you untarred the software.

All Done!

That's pretty much all of the hardware-specific work. Have a lot of fun!


mrjohnson@ibook:~$ cat /proc/cpuinfo

processor : 0

cpu  : 750FX

clock  : 700MHz

revision : 1.18 (pvr 7000 0112)

bogomips : 1389.36


total bogomips : 1389.36

machine  : PowerBook4,3

motherboard : PowerBook4,3 MacRISC2 MacRISC Power Macintosh

detected as : 257 (iBook 2 rev. 2)

pmac flags : 00000003

L2 cache : 512K unified

memory  : 384MB

pmac-generation : NewWorld


References

http://neugierig.org/content/tibook/

http://bulmalug.net/body.phtml?nIdNoticia=1511

http://www.ibooklinux.net/

http://people.debian.org/~branden/ibook.html

http://www.debian.org/ports/powerpc/keycodes