Installing Gentoo on my MacBook

This is a short overview of the steps I undertook to get a nice
Gentoo installation on my brand new MacBook.

It’s far from complete — not even spell-checked — but could be
useful anyway. :-) Please don’t hesitate to href="">contact me with your suggestions,
questions or remarks!


  • Get a MacBook. I got myself a black one with 2Gb of RAM, a
    dutch QWERTY keyboard and 80G of hard disk. I deliberately chose
    for a MacBook and not a MacBook Pro, because the INTEL video
    chipset in the MacBook has better free drivers than the ATI video
    chipset in the MacBook Pro.
  • Get a Gentoo installation CD. A minimal one will suffice if you
    have a connection to the internet available.
  • Inform yourself: a good resource for more information about
    what I’m about to write can be found at the excellent Gentoo documentation wiki on this subject. A good deal of help
    can also be found at #mactel-linux on
  • Install Boot Camp for legacy BIOS emulation (needed for a correct video card
    detection by and easy repartitioning of the harddisk.
  • Install rEFIt, a
    nice EFI boot loader.
  • Repartition your hard disk. Just make the OSX partition as
    small as possible and leave the rest unchanged. You can partition
    it later on.


  • This should be the last time you see your OSX again. :-) But
    don’t worry. Your installation will remain untouched during the
    following process.
  • I hope you are familiar with Gentoo installation. Get the great
    handbook for x86 and enjoy the ride… At a few points I’ll interfere
    with MacBook specific hints.

Where the Gentoo handbook can use some help

2.c. Download, Burn and Boot a Gentoo Installation CD

Don’t bother about wirefree internet for now. Just plug in a
cable and enjoy the Gigabit connection with the sky2 module

4.b. Designing a Partitioning Scheme

You are limited to 4 partitions. 2 are already taken by your OSX
installation, so 2 remain to be used for your favourite OS.

The handbook gives the (good) advice for partitiong your disk
into /, /boot, /home and
swap. This is not possible now, and I chose for the
following scheme:

Output generated by fdisk

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          26      204819+  ee  EFI GPT
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        3812    30408704   af  Unknown
/dev/sda3            3812        7216    27342630   83  Linux
/dev/sda4   *        7216        9729    20192038+  83  Linux

Contents of /etc/fstab

/dev/sda3               /home           ext3            noatime,user_xattr,data=writeback       0 2
/dev/sda4               /               ext3            noatime                     0 1
/swapfile               none            swap            sw                          0 0
/dev/hda                /mnt/cdrom      iso9660         user,noauto,ro              0 0
proc                    /proc           proc            defaults                    0 0
shm                     /dev/shm        tmpfs           nodev,nosuid,noexec             0 0

Output generated by df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda4              19G   14G  4.4G  76% /
udev                  998M  268K  998M   1% /dev
/dev/sda3              26G  1.6G   23G   7% /home
shm                   998M     0  998M   0% /dev/shm

As you probably noticed, I have a swapfile and no swap
partition. With 2Gb RAM you hardly ever swap a page out anyway. :-)
Create it as follows:

Creation of a 2G swapfile

dd if=/dev/zero of=/mnt/gentoo/swapfile bs=1024 count=2097152
mkswap /mnt/gentoo/swapfile
swapon /mnt/gentoo/swapfile
5.e. Configuring the Compile Options

A short overview of the fine fine fine MacBook hardware:

  • The Intel Core Duo processor is from the Prescott family
  • The display controller is an “Intel Corporation Mobile
    945GM/GMS/940GML Express Integrated Graphics Controller”
  • The audio device is an “Intel Corporation 82801G (ICH7 Family)
    High Definition Audio Controller”

Some entries from

CFLAGS="-O2 -march=prescott -fomit-frame-pointer -pipe"
VIDEO_CARDS="i810 vesa"
INPUT_DEVICES="keyboard mouse joystick evdev"
7.b. Installing the Sources

It is advised to start your adventure with a Vanilla kernel and
not with a Gentoo kernel. Additionally, at the time of writing (the
latest stable version of the Linux kernel is 2.6.18), you’ll need
to apply some kernel patches too. Let’s see how this goes.

Patch your vanilla kernel for the

# emerge subversion
# cd /usr/src
# svn co mactel-patches-2.6.18
# cd mactel-patches-2.6.18
(remove 'efi_e820_all_mapped_fix.patch', 'version.patch' and 'sigmatel_audio.patch')
# ./apply /usr/src/linux
7.c. Default: Manual Configuration

There are some kernel configuration options you need to handle
with care. For reference you can download my href="">fully working, not-too-bloaty kernel config.

If you use this kernel configuration, don’t forget to (auto)load
the following modules:

  • uhci_hcd
  • evdev
  • appletouch
  • usbhid
  • mousedev

At least make sure to have the following:

  • CONFIG_SCSI_ATA_PIIX=y or your kernel won’t be able to find
    your hard disk
  • CONFIG_VM86=y or won’t be able to initialize your video
    card via BIOS (read: no X and a lot of headache wondering why)
  • CONFIG_FB_INTEL=y for the framebuffer to work at vga=792
  • CONFIG_SKY2=y for the built-in gigabit network interface to
  • CONFIG_X86_SPEEDSTEP_CENTRINO=y for frequency scaling to
8.a. Filesystem Information

Because we have a swapfile instead of a swap partition, make
sure to tell your system so through /etc/fstab. Simply
replace the swap partition with your swapfile in the first

10.b. Default: Using GRUB

Make sure you emerge >=grub-0.97-r3. My
/boot/grub/grub.conf looks like follows:

My /boot/grub/grub.conf

timeout 10
default 0
fallback 1
title  GNU/Linux Vanilla 2.6.18-mactel-bbb *SPLASH*
root (hd0,3)
kernel /boot/bzImage-2.6.18-mactel-bbb root=/dev/sda4 vga=792 splash=silent,theme:gentoo console=tty1
initrd /boot/initrd-fbsplash
title  GNU/Linux Vanilla 2.6.18-mactel-bbb
root (hd0,3)
kernel /boot/bzImage-2.6.18-mactel-bbb root=/dev/sda4

Also make sure to grub-install grub on your
/ or /boot partition — in this case that
would be /dev/sda4 — and that that partition is marked


Now the fun part can begin: getting all the hardware you paid
for to work perfectly. :-)

Some useful information

First let me post some useful information, like href="">dmesg, lspci, href="">lsusb, lshal, href="">lsdev and cpuinfo.

The hardware

Now let’s go through the hardware and see what we can get to


Gigabit networking over the cable works like a charm with the
sky2 module, included in the kernel.

Wireless networking works fine as well with the
madwifi, which you can find in portage in the
madwifi-ng ebuild. Make sure to enable the
onoe USE-flag.


I just enabled AIGLX and it is lovely. I’m already addicted to
it. You’ll need to unmask some packages for to get to work on
your MacBook though.

First of all you need modular X 7.1:

Extract from my

# Modular X 7.1

Then you’ll have to patch your video BIOS with the 1280×800 mode
with href="">915resolution:

Extract from my



replace=( "5c 1280 800" )

At this point you should be able to get your X up and

Now let’s go on the next level: href="">AIGLX. First, add the
following to your X configuration:

Extract from

Section "DRI"
    Group 0
    Mode 0666
Section "ServerFlags"
    Option         "AIGLX" "true"
Section "Extensions"
    Option         "Composite"   "Enable"
Section "Device"
    Option      "DRI"     "true"
Section "Screen"
    Option      "XAANoOffscreenPixmaps" "true"

Also make sure you don’t load the Mesa GLcore
module. Now you’ll need a compositing window manager. Metacity will
have this functionality from 2.16 on, but today we’ll use href="">Compiz.

Extract from my


Emerge it and then run compiz-aiglx form the
command line. Tzadaaam!


I have a Dutch QWERTY keyboard, but except for the key to the
left of the !/1 it is — as far as I know — identical to an
international QWERTY. Anyway, I just load the us keymap (both in
console and in X) and that works for all other keys. I also found
it useful to change the behaviour of Shift Lock to
Compose Key. Who ever needs Shift Lock

The special keys at the top row (brightness, volume, num lock
and eject) work out of the box in In gnome 2.14 I could just
assign them to their respective actions in Desktop > Preferences
> Keyboard Shortcuts. I didn’t do anything to enable backlight
brightness control yet. To eject a CD in console, emerge and use

Probably you also want the Fn to behave like a
normal Shift or Control key. This is
easily achieved by changing the value of

Extract from my

# have Fn react like the shift button
echo "Teaching \`\`Fn'' how to behave"
echo -n "0x02" > /sys/module/usbhid/parameters/pb_fnmode

Here’s my complete xorg.conf.

In console (gpm)

Just emerge gpm and use the following settings:

My /etc/conf.d/gpm

APPEND="-l \"a-zA-Z0-9_.:~/\300-\326\330-\366\370-\377\" -g 1 -A60 -a 6 -d 5 -2"

This works very fine for me.

In X (synaptics)

The touchpad is recognised as synaptics hardware, so that makes
things easy. Make sure you have the following modules loaded or
compiled into your kernel: uhci_hcd,
evdev, appletouch, usbhid,
mousedev. Then, include the following part in your X

Extract from my

Section "InputDevice"
    Identifier      "Configured Mouse"
    Driver          "mouse"
    Option          "CorePointer"
    Option          "Device"                "/dev/input/mice"
    Option          "Protocol"              "ExplorerPS/2"
    Option          "ZAxisMapping"          "4 5"
Section "InputDevice"
    Identifier       "Synaptics Touchpad"
    Driver           "synaptics"
    Option           "Device"           "/dev/input/mouse1"
    Option           "Protocol"         "auto-dev"
    Option           "LeftEdge"         "100"
    Option           "RightEdge"        "1120"
    Option           "TopEdge"          "50"
    Option           "BottomEdge"       "310"
    Option           "FingerLow"        "25"
    Option           "FingerHigh"       "30"
    Option           "MaxTapTime"       "180"
    Option           "MaxTapMove"       "220"
    Option           "MaxDoubleTapTime"      "180"
    Option           "VertScrollDelta"       "20"
    Option           "HorizScrollDelta"      "50"
    Option           "MinSpeed"         "0.79"
    Option           "MaxSpeed"         "0.88"
    Option           "AccelFactor"      "0.0015"
    Option           "SHMConfig"        "on"
Section "Module"
    Load    "synaptics"
Section "ServerLayout"
    InputDevice     "Configured Mouse"      "CorePointer"
    InputDevice     "Synaptics Touchpad"    "AlwaysCore"

Tap-to-click, horizontal and vertical scrolling all work with no

I assume you’re also interested in getting a middle and a right
mouse button. For that, I use the — otherwise completely unuseful —
apple keys. Try the following:

Extract from my

# emulating middle and right click
echo "Enabling middle- and rightclick"
echo 1 > /proc/sys/dev/mac_hid/mouse_button_emulation
echo 125 > /proc/sys/dev/mac_hid/mouse_button2_keycode # 125 = left apple
echo 126 > /proc/sys/dev/mac_hid/mouse_button3_keycode # 126 = right apple

First of all: forget about oss, move on to
alsa. The hardware in your MacBook is managed
perfectly by the hda-intel module. You can use the
version included in the kernel, but there are some problems
reported with them. I use the
media-sound/alsa-driver-1.0.13 ebuild from portage.
This works fine.