The latest apt-get update && apt-get upgrade had a kernel update to 2.6.18-5. This kernel is still missing some of the Macbook patches, so I had to get the source, patch and build a package. This took longer than I thought, because a few things had changed. So, here are the bits and pieces that I had to do to get my Macbook back to working the way it had been.

Firstly get the source for this new kernel with apt-get source linux-image-2.6.18-5-686. This downloads the kernel source to a linux-2.6-2.6.21 directory.

If you haven’t already, get the Mactel patches from the Subversion repository at https://mactel-linux.svn.sourceforge.net/svnroot/mactel-linux/trunk; cd into the kernel/mactel-patches-2.6.21/ directory and run ./apply /path/to/linux/source.

At this point, you should configure the kernel. To do this, I used make oldconfig. You can go with the default on most of the new options you’re prompted on I think. The only ones I changed were some of the Apple specific ones. Watch out for them, and decide yourself if you want to include them. I can’t remember off-hand right now what they were.

After building, installing and booting this new kernel, it looked like the harddrive was renamed from sda to hda. However, using hda only got the system to boot a small bit further (this was using a root=/dev/hda3 kernel boot parameter, and changing sda to hda in /etc/fstab). To fix this, in the kernel configuration (I used make menuconfig), do the following

  • Under Device drivers, turn off ATA/ATAPI/MFM/RLL Support
  • Under Serial ATA (prod) and Parallel ATA (experimental) drivers, set both ATA device support and Intel ESB, ICH, PIIX3, PIIX4, PATA/SATA support to ‘m’ (to build kernel modules instead of compiling support into the kernel)

While you’re configuring the kernel, do the following also, if, like me, you change the order of the F keys and the FN keys.

  • Under HID Devices, set Generic HID support to ‘m’ instead of ‘y’

I like the F keys first, so in previous kernels I set pb_fnmode=2 for the usbhid module. However, this option moved to the hid module at some point, but in the default debian kernel build, hid is built into the kernel. I rebuilt it as a module and put

options hid pb_fnmode=2

into /etc/modprobe.d/options. If you have a similar line for usbhid in there already, comment it out.

At this point, you should compile and install your new kernel. The commands below also create a kernel headers package, as well as the kernel image package, which you can skip if you don’t require it.

make-kpkg clean
make-kpkg –initrd kernel-image
make-kpkg kernel-headers
dpkg -i ../linux-image-2.6.21-mactel*
dpkg -i ../linux-headers-2.6.21-mactel*
lilo

I’m using lilo as the bootloader. If you’re using grub, replace the lilo command above with grub-install to update the MBR with the new kernel image.

You can now reboot to the new kernel.

The last thing I can think of is to install the madwifi drivers for the wireless card.

apt-get install madwifi-source
cd /usr/src
tar xjvf madwifi.tar.bz2
cd modules/madwifi
make
make install

This depends on the kernel headers package being installed. If you didn’t create one, or didn’t install it, you can build the modules with

make -C /path/to/linux/source SUBDIRS=`pwd` modules
make -C /path/to/linux/source SUBDIRS=`pwd` modules_install

I think that covers most of what I had to do to get 2.6.21 running.