Introduction

At the time of writing, my main computer was an Apple Powerbook G4, bought during August as a portable Unix box. Instead of Mac OS X, I usually ran Debian GNU/Linux on it; this page documents how I got it working, some of the decisions I made, and the reasons for them. I've also included some useful bits of configuration.

This page assumes that you've installed Linux before, preferably Debian — installing Linux for the first time on a non-x86 laptop is not particularly advisable. I suggest experimenting with an old Pentium MMX or Pentium II class desktop first :-)

Running a niche OS on a niche platform might seem like a silly thing to do — most proprietary software (even if written for Linux, like the nVidia video drivers I use on my desktop) won't work because I'm not using an x86 processor, even some open-source software runs into problems (because it assumes x86 properties) when compiled for PowerPC, and finding people who can help me is harder (since most Linux users run x86). At the same time, relegating Mac OS X to a secondary OS means I don't even get some of Apple's unique selling points (ease of use and pretty graphics).

On the other hand, Apple do make pretty solid hardware, and their industrial design is wonderful; Debian is a stable and consistent distribution with a ridiculous amount of packaged software, so the combination ought to be pretty good. On the geekier side of things, the PowerPC architecture is apparently better for ‘virtualizing’ than x86, so it's possible to get the best of both worlds by running both Linux and Mac OS simultaneously, without as much overhead as something like VMWare or Plex86 would produce. Running a niche OS on a niche architecture also means I'm highly unlikely to get a virus, or at least one I can execute :-)

Specification

The particular model I bought (from the online Apple Store, using Cambridge University's impressive student discount) was basically the high-end version of the final Titanium Powerbook model, but with the DVD-R/CD-RW drive downgraded to a DVD-ROM/CD-RW (I couldn't really justify the extra cost to get DVD-R capabilities). If you happen to have this or a similar model, all the advice on this page is likely to work; if not, your mileage may vary.

Base system
1GHz G4 CPU, 512MB RAM
Storage
60GB hard disk, ‘combo drive’ (DVD-ROM/CD-RW)
Video
ATi Radeon Mobility 9000 M9, 1280x854 LCD panel, DVI/VGA/TV output
Audio
On-board audio, built-in speakers, headphone out, line in
Communication
56k modem, 10/100/1000 MBit Ethernet, 802.11b 11MBit wireless networking, 2×USB, Firewire

Installation

I mostly followed the excellent instructions Debian developer Branden Robinson provides for Debian on an iBook, which still seem to be valid for a Powerbook.

I initially installed a pretty basic system — in particular, I didn't install any of the collections of software suggested by tasksel, or XFree86. I did install a couple of utilities I knew I'd be lost without (aptitude, sudo), a reasonable console text editor (joe), a text-mode web browser to download things with (lynx), and enough tools to compile a kernel (build-essential and kernel-package).

I'd gathered from various web pages that PowerMac systems weren't well supported in older software, so the next step was to edit /etc/apt/sources.list and switch my APT sources from stable to unstable. Since Debian is fairly conservative, unstable is usually far enough from the bleeding edge to be usable :-)

The next step was to replace my kernel with a custom one. For the initial compile I used the "benh" kernel source (Ben H is one of the main PowerPC Linux developers), obtained via rsync according to the instructions provided by penguinppc.org. I also needed X direct rendering modules, for which I compiled Michel Dänzer's more up-to-date versions of the normal DRI kernel modules, obtained by adding the line shown here to /etc/apt/sources.list.

deb http://people.debian.org/~daenzer/dri-trunk-sid ./

(Incidentally, if you use Debian and compile your own kernels without using kernel-package, I suggest trying it — it makes everything much easier.)

Once I'd rebooted with the new kernel, I installed XFree86, or rather the DRI trunk variant of XFree86, also from Michel Dänzer's apt repository; after some trial and error, I managed to get it working OK (see below for the configuration) and could start installing the other stuff I wanted. By now I've accumulated several gigabytes of software including KDE 3.1, Openoffice.org, a fairly comprehensive set of compilers, various network tools, and so on.

Kernel and modules

You probably want at least kernel-source-2.4.22, alsa-source, drm-trunk, and kernel-patch-2.4-benh; I also use kernel-patch-preempt, mol-modules-source (Mac On Linux), freeswan-source (FreeS/WAN) and a couple of local patches.

FIXME: needing to undo HXu's IPSec patch; which hardware and options you want on a TiBook IV; local patches.

XFree86

Required kernel options
AGP support (CONFIG_AGP=y)
Apple UniNorth AGP (CONFIG_AGP_UNINORTH=y)
Direct Rendering Management, current version (CONFIG_DRM=y, CONFIG_DRM_NEW=y)
ATI Radeon driver disabled or in a module (CONFIG_DRM_RADEON=n or CONFIG_DRM_RADEON=m)
Required extra kernel modules
drm-trunk-module-src from Michel Dänzer's apt repository (load the radeon module)
Required packages
xserver-xfree86-dri-trunk, xlibmesa-gl1-dri-trunk from Michel Dänzer's apt repository

Since XFree86's Direct Rendering Infrastructure is under active development, particularly for use on Apple hardware, I use "cutting-edge" packages from Michel Dänzer's unofficial apt repository (see above for the address). These override the usual Radeon drivers and provide a more up-to-date version of the driver.

My /etc/X11/XF86Config-4 configuration file follows. Note that I sometimes use an external mouse and an external monitor; the mouse works fine, but to use the external monitor I have to swap the order of the two ServerLayout sections and restart the X server (I use kdm as my display manager, so to restart the X server I log out, press Ctrl+Alt+Backspace, wait for kdm to start, and log back in).


Section "ServerLayout"
	# Normal server layout for the Powerbook on its own
	Identifier  "powerbook"
	Screen 0 "ati-radeon-m9+powerbook-lcd" 0 0
	InputDevice "usb-explorer" "CorePointer"
	InputDevice "powerbook-kb" "CoreKeyboard"
EndSection

Section "ServerLayout"
	# Server layout for the Powerbook plus my external monitor
        Identifier     "powerbook+iiyama"
        Screen 0       "ati-radeon-m9+powerbook-lcd" 0 0
        Screen 1       "ati-radeon-m9+iiyama-vmp400+1152" Above "ati-radeon-m9+powerbook-lcd"
        InputDevice    "usb-explorer" "CorePointer"
        InputDevice    "powerbook-kb" "CoreKeyboard"
        Option          "Xinerama"
EndSection

Section "Files"
    RgbPath     "/usr/X11R6/lib/X11/rgb"
    ModulePath  "/usr/X11R6/lib/modules-dri-trunk"
    FontPath    "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
    FontPath    "/usr/share/fonts/ttf"
    FontPath    "/var/lib/defoma/x-ttcidfont-conf.d/dirs/CID"
    FontPath    "/usr/lib/X11/fonts/misc"
    FontPath    "/usr/lib/X11/fonts/100dpi/:unscaled"
    FontPath    "/usr/lib/X11/fonts/75dpi/:unscaled"
    FontPath    "/usr/lib/X11/fonts/Type1"
    FontPath    "/usr/lib/X11/fonts/Speedo"
    FontPath    "/usr/lib/X11/fonts/100dpi"
    FontPath    "/usr/lib/X11/fonts/75dpi"
EndSection

Section "Module"
	Load	"dbe"
	Load	"extmod"
	Load	"type1"
	Load	"freetype"
	Load	"dri"
	Load	"glx"
	Load	"record"
	Load	"speedo"
	Load	"xtrap"
EndSection

Section "InputDevice"
        Identifier      "powerbook-kb"
        Driver          "keyboard"
        Option          "XkbRules"      "xfree86"
        #Option         "XkbModel"      "macintosh"
	# Amend as necessary if you aren't used to touch-typing on a British
	# keyboard
        Option          "XkbLayout"     "gb"
EndSection

Section "InputDevice"
	# This is for a Microsoft Intellimouse Explorer, but should work OK
	# for any USB mouse; it also works fine with the built-in trackpad
	Identifier	"usb-explorer"
	Driver	"mouse"
	Option "Protocol"    "ExplorerPS/2"
	Option "Device"      "/dev/input/mice"
	Option "Buttons" "4"
	Option "ZAxisMapping" "6 7" # this is a bit of a hack, see below
	Option "AlwaysCore" "1"
EndSection

Section "Monitor"
        Identifier   "powerbook-lcd"
        VendorName   "Apple"
        ModelName    "TiBook IV"
        Mode "1280x854"
          DotClock 79.816
          HTimings 1280 1296 1408 1536
          VTimings 854 855 858 866
          Flags "-HSync" "-VSync"
        EndMode
EndSection

Section "Monitor"
	# !!! WARNING
	# The modelines below are specific to my monitor, which is a pretty
	# good 17" one. Using these modelines with a different monitor will
	# probably not work.
	# Use of incorrect modelines could cause permanent damage to some
	# older monitors - you have been warned!
	Identifier      "iiyama-vmp400"
	VendorName      "iiyama"
	ModelName       "Vision Master Pro 400"
	HorizSync       27-96
	VertRefresh     50-160
	Option	"DPMS"
	Modeline	"1600x1200"	162.00 1600 1684 1876 2148 1200 1201 1204 1250 +hsync +vsync
	Modeline	"1280x1024"	135.00 1280 1300 1404 1648 1024 1027 1030 1056
	Modeline	"1152x864"	135.00 1152 1188 1316 1524 864 864 876 908
	Modeline	"1024x768"	98.90 1024 1072 1232 1356 768 770 776 798 -hsync -vsync
	Modeline	"800x600"	60.75 800 864 928 1088 600 616 621 657 -hsync -vsync
	Modeline	"640x480"	30.00 640 672 736 796 480 483 486 501 -hsync -vsync
EndSection

Section "Device"
	# The Radeon M9 connected to the Powerbook's LCD panel
	# Note that UseFBDev is true here
        Identifier  "ati-radeon-m9"
        Option  "AGPMode"               "4"
        Option  "AGPFastWwrite"         "true"
        Option  "EnableDepthMoves"      "true"
        Option  "EnablePageFlip"        "true"
        Option  "NoBackBuffer"          "false"
        Option  "NoAccel"               "false"
        Option  "SWcursor"              "false"
        Option  "UseFBDev"              "true"
        Option  "DDCMode"               "true"
        Driver      "radeon"
        VendorName  "ATI Technologies Inc"
        BoardName   "Radeon Mobility M9"
        BusID       "PCI:0:16:0"
        Screen 0
EndSection

Section "Device"
	# The Radeon M9's VGA port; note that UseFBDev is false here
        Identifier  "ati-radeon-m9-vgaout"
        Option  "AGPMode"               "4"
        Option  "AGPFastWwrite"         "true"
        Option  "EnableDepthMoves"      "true"
        Option  "EnablePageFlip"        "true"
        Option  "NoBackBuffer"          "false"
        Option  "NoAccel"               "false"
        Option  "SWcursor"              "false"
        Option  "UseFBDev"              "false"
        Option  "DDCMode"               "true"
        Driver      "radeon"
        VendorName  "ATI Technologies Inc"
        BoardName   "Radeon Mobility M9"
        BusID       "PCI:0:16:0"
        Screen 1
EndSection

Section "Screen"
        Identifier "ati-radeon-m9+powerbook-lcd"
        Device     "ati-radeon-m9"
        Monitor    "powerbook-lcd"
        DefaultDepth 24
        SubSection "Display"
                Depth     16
                Modes "1280x854"
        EndSubSection
                SubSection "Display"
                Depth     24
                Modes "1280x854" 
        EndSubSection
EndSection

Section "Screen"
	# When using a "dual-head" display setup, I run my external monitor
	# at the standard 1152x864 resolution, but increase its "virtual" width
	# to 1280 pixels so it matches the laptop's LCD.
	# You can reach the extra space by moving the mouse cursor off the
	# sides of the screen.
        Identifier "ati-radeon-m9+iiyama-vmp400+1152"
        Device     "ati-radeon-m9-vgaout"
        Monitor    "iiyama-vmp400"
        DefaultDepth 24
        SubSection "Display"
                Depth     16
                Modes "1152x864"
                Virtual 1280 864
        EndSubSection
        SubSection "Display"
                Depth     24
                Modes "1152x864"
                Virtual 1280 864 
        EndSubSection
EndSection

Section "ServerFlags"
	#    Option "NoTrapSignals"
	#    Option "DontZap"
	#    Option "Dont Zoom"
	#    Option "DisableVidModeExtension"
	#    Option "AllowNonLocalXvidtune"
	#    Option "DisableModInDev"
	#    Option "AllowNonLocalModInDev"
EndSection

Section "DRI"
	# On Debian systems, the "audio" group is a convenient one to
	# represent the users who can do hardware-accelerated 3D
	Group "audio"
	Mode 0660
EndSection

XFree86 keyboard

The XFree86 config above uses a standard PC-style British keyboard layout, not the Mac British keyboard layout that's printed on the keycaps. I'm used to touch-typing on British PC keyboards, so I prefer to use this layout and just ignore what's printed on the keys (and I wish I could configure Mac OS X to do the same). The differences are:

  • the key to the left of 1 produces the backquote and ‘not’ sign , not the plus-or-minus and section symbols ±§
  • Shift-2 is ", not @
  • Shift-apostrophe is @, not "
  • the key to the left of Z produces the backslash and vertical bar \|, not the backquote and tilde `~
  • the key to the the right of the apostrophe produces the hash sign and tilde #~, not the backslash and vertical bar \|

Normally, XFree86 maps the Ctrl key to left Ctrl, both Shift keys to left Shift, the Option key (also marked ‘alt’) to left Alt, and the Command key (the one with the Apple logo and the ‘splat’ symbol) to left Super (Super is an extra modifier, often assigned to the Windows key on Linux PCs; there's yet another modifier called ‘Hyper’ if you have a spare key to assign it to).

With the Fn key down, the Powerbook sends different keycodes (Linux has no control over this). This time XFree86 maps the Ctrl and both Shift keys to right Ctrl and right Shift, the Option key to Mode Switch (a.k.a. right Alt, or Alt.Gr, on a PC) and the Command key to the Compose key.

Mode Switch lets you get extra characters, much like Shift (on my UK keyboard map, Fn+Option+4 becomes Mode Switch+4, which is the Euro sign “€”, for instance). Compose is a great feature - after you press and release Compose, X will try to “compose together” the next two keys you press, in some sensible way, in order to get a more complicated character. For instance, Compose-E-= gives you a Euro sign, Compose-`-` and Compose-'-' give you opening and closing double quotes, Compose-A-: produces ä and Compose-O-C gives the copyright symbol ©.

Audio

Required kernel options
Sound (CONFIG_SOUND)
The old OSS sound drivers as modules, or not at all (either CONFIG_DMASOUND=m, CONFIG_DMASOUND_PMAC=m or CONFIG_DMASOUND=n, CONFIG_DMASOUND_PMAC=n)
(for 2.4 kernel) external alsa-source modules compiled along with your kernel (you want the snd-powermac driver)
(for 2.6 kernel) ALSA drivers (CONFIG_SND, CONFIG_SND_SEQUENCER, CONFIG_SND_OSSEMUL, CONFIG_SND_MIXER_OSS, CONFIG_SND_PCM_OSS, CONFIG_SND_SEQUENCER_OSS) with snd-powermac driver (CONFIG_SND_POWERMAC)
Required packages
alsa-base, alsa-utils, alsa-source (for 2.4 kernel)
I use ALSA. See ALSA with dmix.

Storage

FIXME: use of ide-scsi.

Mouse configuration

Required kernel options
USB support (CONFIG_USB, CONFIG_USB_OHCI)
USB HID mouse (CONFIG_USB_HID, CONFIG_USB_HIDINPUT, CONFIG_USB_HIDDEV)
generic input layer and mouse support (CONFIG_INPUT, CONFIG_INPUT_MOUSEDEV)
Mac mouse button emulation (CONFIG_MAC_EMUMOUSEBTN)
Required packages
hotplug

Trackpad/mouse switching

I ususally use a USB mouse (a Microsoft Intellimouse Explorer, OEM version, which is the first Microsoft product I've bought for years). When not using that, I use the built-in trackpad.

The problem with that is that the trackpad only has one button, and X really wants at least three. The Mac input layer contains a workaround - you can remap keys to be virtual mouse buttons. The following incantations in /etc/sysctl.conf set up F10 and F11 as mouse buttons:

dev/mac_hid/mouse_button_emulation=1
dev/mac_hid/mouse_button2_keycode=68
dev/mac_hid/mouse_button3_keycode=87

However, this means I lose two quite useful keys (F10, in particular, is the "menu" key in aptitude). To reclaim them, I use the following script, which I place in /etc/hotplug/usb/mousedev to be auto-run when the mouse is detected; when I unplug the mouse, the script automagically restores the mouse button emulation.

#!/bin/sh
# /etc/hotplug/usb/mousedev
# Mouse button emulation switch for Apple Powerbook with external mouse

if [ '3/1/2' = "$TYPE" ] || [ '3/1/2' = "$INTERFACE" ]
then
        case "$ACTION" in
                add)
                        logger -t hotplug-usb-mousedev -p daemon.info \
                                "add USB mouse"
                        echo "0" > /proc/sys/dev/mac_hid/mouse_button_emulation
                        cat > $REMOVER <<"END"
#!/bin/sh
/etc/hotplug/usb/mousedev remove
END
                        chmod u+x $REMOVER
                        ;;
                remove)
                        logger -t hotplug-usb-mousedev -p daemon.info \
                                "remove USB mouse"
                        echo "1" > /proc/sys/dev/mac_hid/mouse_button_emulation
                        ;;
                *)
                        logger -t hotplug-usb-mousedev -p daemon.info \
                                "unknown action $ACTION"
                        echo "mousedev: Unknown action $ACTION" >&2
                        ;;
        esac
fi

Mouse wheel

The standard for wheel mice in X is to have buttons 1-3 as real physical buttons, buttons 4 and 5 as the two scroll directions of the wheel; most applications interpret wheel movement as scrolling. My mouse already has 5 real buttons (if you count clicking the wheel as a middle button, which is conventional) which X insists on calling buttons 1 to 5, so I can't do that.

As a workaround, in the XFree86 configuration above I map the wheel to buttons 6 and 7, which I don't have. In my .xsession X initialization script, I reconfigure the mouse to use a more conventional mapping:

xmodmap -e "pointer = 1 2 3 8 9 4 5"

This sets the wheel to produce button 4 and 5 clicks when scrolled, and turns the thumb buttons into buttons 8 and 9.

Networking

FIXME: ifplugd; my weird ad-hoc networking setup. Wireless networking stuff.

Power management and special keys

FIXME: PMUd. ikeysd, not pbbuttonsd.

Not tested

I have not tested the following features:

  • Gigabit ethernet: the Sun GEM network chip apparently supports 1000MBit operation, but I don't have any other network kit that can do this, and I tend to find 100MBit is plenty for normal use anyway :-)
  • Esoteric USB devices: I've only used USB for a printer (HP Deskjet 840C), a mouse, and a SmartMedia card reader (all of which worked perfectly).
  • Firewire
  • Modem
  • Audio line-in
  • Graphics card TV-out