Translation(s): English - Español - Français


What is a MacBook

MacBook is a series of Notebook PCs sold by Apple Inc. since around 2006. There are several different models with different internal hardwares, and you will usually get the latest version available. You can check which version by looking at Mac OS X "about this Mac" menu, or dmidecode output from Linux.

(Please fill in as appropriate)

Basic situation of MacBook with Debian

For most people, chain loading BIOS compatible classic bootloaders via rEFIt installed to MacOS X is easiest to set up and works well.

<!> You should use the latest lenny installer CD by now. The kernel for lenny is 2.6.26 series. It is good idea to upgrade your kernel to the backported one (2.6.30 series) for better hardware supports.

<!> Make sure you’ve received the latest Apple updates in OS X. This is needed because the latest updates include a BIOS compatibility layer we are going to use to boot Debian.

Pure Debian system by direct EFI bootloaders may leave you without 3D acceleration unless the latest kernel with proper KMS support is used. But it seems to be possible these days. For daring spirit people, please read the following.

Many issues reported on EFI compatible bootloaders and related packages are being resolved and these packages are in Debian. See their BTS and PTS for the latest bug and source package situation:

Relevant information elsewhere on this wiki: MacMiniIntel and MacBookPro.

Following contain many detailed information.

Pros and cons of a MacBook for Linux users

Pros:

Cons:

Debian installation

See also: InstallingDebianOn/Apple

Single boot – Debian only

This requires you to set up system with EFI bootloader. We should see this happen real soon for squeeze.

From wheezy, We can do single-boot without rEFIt, use GRUB as bootloader. The following is old information.

Old infomation

If you want to use rEFIt, follow the advice under Double boot. Note that you will need to boot into mac os X one last time to set up rEFIt. Also note that you should not use the use whole disk option in the debian installer, as this is going to destroy the EFI partition which is used by rEFIt. So you should first shrink your mac os x partition by 1G, then partition that 1G into /boot and /, make /boot bootable, and install a minimal system in your 1G /. tell rEFIt to boot from /boot, check the system boots ok. Then repartition (wiping the mac partition, preserving the EFI partition and /boot), reinstall debian onto your whole drive, re-using the same /boot. Hopefully, you should have a working single-boot debian macbook. Note that this procedure is untested, as the author wrote it as a result of wiping his own EFI partition by using use whole disk in the installer. Please report results if you attempt it.

Here's a report: it doesn't work. Deleting the MacOS partition causes the system bootloader to not find anything to boot, even rEFIt. DO NOT DO THIS. --frozencemetery

Double boot - Mac OS X & Debian

Partitioning (via OS X)

Before you can install Debian, you have to physically make space for it on the hard drive. You can either (re)partition the whole disk or shrink the existing Mac OS X partition, there is more than one way to do it.

Hint: It is not really necessary to create linux partitions at this point (this can be done during the installation of Debian), but it might be advantageous for two reasons. Firstly, The Mac OS X Disk Utility behaves strangely if you just request free space and do not define a file system, see below. Secondly. It is important that the Linux system partition is a primary partition (number 1 to 4), see Section "Install Debian". This can be secured by creating and verifying it early in the process. If you define Linux partitions at this stage, consider also to create a partition for exchanging data between Linux and Mac OS X, see Section "Cross-mount file systems" below.

Partition disk with Disk Utility: In the initial phase of the installation procedure for Mac OS X you can use the 'Disk Utility' partition tool that you can find in the 'Installer' by clicking on 'Utilities' -> 'Disk Utility'. This tool is a bit erratic. It likes to move partitions around and change their sizes when you perform the final step of partitioning. We finally succeeded with the following method:

  1. Within the Disk Utility click on the hard drive entry (not any of its subentries).
  2. Click on 'Partition' (between 'Erase' and 'RAID').
  3. Under 'Volume Scheme:' choose the number of partitions. Don't use 'Split' and 'Delete', this seems to confuse the program.
  4. Then work your way from the top partion to the bottom one. Always select a Format (for later Linux partitions use 'UNIX File System', avoid 'Free Space') and mark 'Locked for editing'.
  5. Click on 'Partition' in the bottom right and cross your fingers. It has been observed that 'Disk Utility" hangs in an 'infinite' loop forever.
  6. To verify that the program did the partitioning as you intended, leave 'Partition' (e.g. by clicking on 'First Aid') and reenter it (by clicking on 'Partition' again). Check whether the actual partitioning is what you want.

Hint: The partitions made by the 'Disk Utility' will be numbered beginning with 2, probably to have number 1 left for rEFIt. Thus, to make sure the Linux system partition is a primary one it must be one of the first three partitions.

Shrink Mac OS X partition with diskutil: If you have Mac OS X installed already and don't want to reinstall it (and thereby erase all data), you can use the diskutil program to shrink the Mac OS X partition. This can be done on the current system partition, there is no need to boot from CD. Supposing you want to reserve 20GB for your Mac OS X partition, run the following command from a terminal (Applications -> Utility -> Terminal):

Mac OS X $ sudo diskutil resizevolume disk0s2 20G
Started resizing on disk disk0s2 Macintosh HD
Verifying
Resizing Volume
Adjusting Partitions
Finished resizing on disk disk0s2 Macintosh HD
WARNING: You must now reboot!

Support for the resizevolume verb was added in Mac OS X 10.4.6. If you have an earlier version, you'll need to upgrade.

The program diskutil can also add partitions, see its man page. But note that it doesn't provide a way to remove partitions.

Preparing to dual boot (via OS X): rEFIt

First install the latest rEFIt from rEFIt homepage. For optional manual installation, please read rEFIt install documentation. If you don't have your MacBook connected to the internet, you can download the rEFIt Mac disk image onto a USB memory stick and install rEFIt from there by double clicking on rEFIt-0.10.dmg (or whatever version you have) and then on rEFIt.mpkg.

NOTE: The combination of pre-0.9 rEFIt and GNU parted is known to cause problems: see http://refit.sourceforge.net/doc/c4s5_parted.html. If you install an old version of rEFIt and then install Debian + Lilo, you might not be able to install Grub afterwards. Reinstalling rEFIt 0.9 or greater will fix this problem.

It's now possible to proceed with installing Debian.

Note refit doesn't support making linux the default boot choice in triple-boot environments, so you might want to look into other options. rEFIt does support making GNU/Linux the default choice when dual-booting. From OS X, edit the /efi/refit/refit.conf file and uncomment/add the line legacyfirst:

sed -e 's/#\(legacyfirst\)/\1/' -i~ /efi/refit/refit.conf

Install Debian

Get an installation CD: Burn yourself a lenny Debian installation CD (i386 or amd64 version, 1st CD/DVD of full CD/DVD set). CD-images are available from http://www.us.debian.org/distrib/.

Using amd64 version is now OK. The main issues are with 32bit packages such as Java and flash, but it think that's unrelated. If there are still issues please capture them here)

Installing Grub2 has also been fine for Lenny. This is the grub-pc version which boot through rEFIt (not grub-efi). This is tested on amd64 and i386.

Boot from installation CD: Insert the Debian installation CD and hold down the c-key while booting. This should bring up the Installation CD welcome screen. Simply press return there and proceed with the installation.

[!!] Choose language ...

[!] Select a keyboard layout ... (unfortunately, as there is no mac keymap on netinstall CDs, the external USB keyboard is appreciated.)

[!!] Configure the network: (Useful for netinstalls. The easiest is to do it via DHCP.)

[!!] Partition disks: While only the "/" system partition is necessary, you should consider to add a swap partition.

When creating new partitions for Linux, take care that the Linux boot/system partition is among the first four partitions, i.e. is a primary partition. There are reports that rEFIt does not notice partition five and higher Linux auf einem MacBook Pro. Also consider creating a partition for exchanging data between Linux and Mac OS X, see Section Cross-mount file systems below.

Mark the "/" (or "/boot" if you created it) as bootable.

Also make sure all partitions are formatted and have a known file system type. Otherwise you get in trouble further below, see TROUBLESHOOTING (GPT partition of type 'Unknown' found, will not touch this disk.). Partitions with free space are ok.

[!!] Set up users and passwords ...

[!] Configure the package manager: (refit is included in version 4.0_r3, but you should still configure a mirror)

[!] Configuring popularity-contest ...

[!] Software selection: Select the Laptop here (in addition to the defaults Desktop environment and Standard system).

[!!] Configuring uswsusp:

[!] Install the GRUB boot loader on a hard disk: Do not install the GRUB boot loader. Instead, leave this menu item and return to the main menu by selcting <Go back>.

Synchronize MBR and GPT: Switch to the second virtual console by pressing ctrl-alt-F2 [or possibly fn-ctrl-alt-F2], press return to start the shell, and then enter

 chroot /target
 aptitude install refit
 gptsync /dev/sda

or, if refit fails, install gptsync instead. It's gptsync that you need. Gptsync comes with refit but can be installed separately.

 chroot /target
 aptitude install gptsync
 /target/sbin/gptsync /dev/sda

and enter 'y' at the prompt. This synchronizes the MBR from the GPT, which were made out of sync by parted.

(The directory /target is the directory in which the Debian installer installs the new system and it later becomes the root directory /.)

Then switch back to the first virtual console by pressing ctrl-alt-F1 [or possibly fn-ctrl-alt-F1] [or possibly fn-ctrl-alt-F5].

[!!] Install the LILO boot loader on a hard disk: In the main menu choose select "Install the LILO boot loader on a hard disk". Choose /dev/sda3 (or whatever your new Debian partition is) for the LILO installation target. Do not install LILO to the MBR! When the installer asks whether you want to make this partition active, choose "No."

<!> If you forgot to run gptsync, you need to take care it using refit GUI menu.

{i} There may be some glich if you follow menu to install GRUB to MBR /dev/sda instead of /dev/sda3 as described above. Some people reports that GRUB (stage 1.5?) needs a partition with bios_grub flag set. This can be done with parted by setting the EFI partition (no. 1) as bios_grub. You should be very careful and check for other boot code before (using refit partition analyser under OS X), as this might render your system unbootable.

[!!] Finish the installation: Remove the ejected installation CD and select <Continue>. During reboot select Linux from the Mac rEFIt menu.

GRUB as bootloader

Installing lenny using GRUB

Lenny install CD can install GRUB as bootloader. Its dialogue can be misleading if you wish to install bootloader to MBR. You must create proper MBR/GPT hybrid. It can be done by:

Switching from LILO to GRUB

If you wish to switch from lilo to GRUB:

The package to use is the grub-pc package, which uses GRUB 2. (GRUB Legacy is no longer supported.)

Boot Loader

The most delicate part of installing operating systems, other than drive partitioning (which can destroy data), is configuring the boot loader, which can render your system unbootable. Best practice has been changing with improved development of GRUB and supporting software.

Currently the best stable (lenny and squeeze) configuration is:

This allows multi-booting to Linux, Mac OS X, and Windows, yields accelerated hardware, and does not require LILO to be run every time a kernel or init ramdisk change occurs. For squeeze installer, this is the default.

In future, but not in squeeze, it may be able to use:

This is supposed to be simpler to rEFIt + GRUB 2 (BIOS version), but it may lack 3D acceleration.

In the past, (etch?), pratice was:

This worked, but had the usual limitations of LILO (system wouldn’t boot if forgot to run lilo after kernel changes, etc.), and was necessary because GRUB Legacy does not support Macbooks.

Any OS can be selected as default if you use GRUB 2 in EFI, or rEFIt then the BIOS version of GRUB 2 (so long as Linux is the first non-Mac partition).

See IntelMac/BootLoader for further details.

Cross-mount file systems

To make a double boot system really useful it is desirable to cross-mount file systems, i.e. to make Mac OS X-filesystems readable (and writable) under Linux and vice versa. Mac OS X uses a file system called HFS+ while Linux uses ext3.

Even though cross-mounting is possible in either direction, there seems to be some scepticism (and possibly bad experience?) concerning the reliability, so that the common advice seems to be to only use small partitions mounted under both operating systems and use them for data exchange. Mounting and using large partitions for regular usage under both operating systems seems to be not advisable. (Please let us know if you have experience with that.)

Mount Mac OS X filesystems (HFS+) under Linux

If you want to mount a Mac OS X-filesystem under Linux in read-write mode (not read-only) then you have to turn off journaling first under Mac OS X. If you leave journaling on, you can only mount in read-only mode and will not be able to write or modify files in the Mac OS X-filesystem. This is a trade-off, of course, because journaling gives you security that your Mac system lacks if you turn it off. It might thus be advisable to have one partition for the Mac operating system with journaling (which is the default) mounted from Linux read-only (if at all) and one partition with user data without journaling mounted from Linux read-write. See HOWTO hfsplus for more information about HFS+ under Linux.

Step 1 (if mounting read-write) - turn off journaling under Mac OS X: If you want to mount the Mac OS X-filesystem in read-write mode (not read-only) then you have to turn off journaling.

(i) Boot into Mac OS X.

(ii) Start a terminal.

(iii) As root (e.g. with sudo) use diskutil to turn off journaling (Disabling journaling via diskutil):

mac:user> sudo /usr/sbin/diskutil disableJournal /data

This assumes your partition is mounted to the directory /data. If you want to turn off journaling for your Mac operating system partition, use / instead.

(iv) Reboot into Linux.

Step 2 - mount the Mac OS X-filesystem under Linux: If /dev/sda2 contains the HFS+-filesystem of the Mac OS X you want to mount, then run under Linux the following as root Dave Taylor, 2005-05-14.

root# mkdir /media/macdata
root# mount -t hfsplus /dev/sda2 /media/macdata

This mounts /dev/sda2 on the directory /media/macdata (only read-only if the HFS+ partition is using journaling, which is the default when Mac OS X creates a HFS+ partition). Of course, you can also create and mount on a different directory.

Step 3 (optional) - edit fstab to auto-mount at boot time: If you want to mount the partition automatically at boot time, you have to add an entry like the following in the file /etc/fstab.

/dev/sda2   /media/macdata   hfsplus   defaults   0   2

TROUBLESHOOTING (cannot write on HFS+ filesystem anymore): If you cannot write on the HFS+ filesystem anymore, boot into Mac OS X and perform a filesystem check, maybe that helps Linux on an Apple iBook G4.

Mount Linux filesystems (ext3) under Mac OS X

To mount Linux filesystems (ext3) under Mac OS X the best open source option is to use MacFUSE and Fuse ext2. Once installed, reboot and execute:

$ cd /Volumes
$ mkdir  Linux_Home
$ sudo fuse-ext2 /dev/disk0s5 Linux_Home/

You should now see your partition in the finder.

Hardware configuration

Devices that work

The following features work for lenny (kernel 2.6.26):

In addition to these, the following features work for lenny with kernel from backports.org (kernel 2.6.30):

(See below for more)

Backlight + Volume + CD Eject button

Backlight keys (Fn+F1 and Fn+F2) work using Julien Blache's pommed (there is a new project homepage at alioth); you can even turn off the backlight using the keyboard; pommed also enables the CD Eject button's functionality, Fn behaviour and remote control. Besides, you can also install gpomme: a GTK+ client suitable for all environments (you should start it when your session starts) and wmpomme (a ?WindowMaker dockapp)

By default on Debian testing, the F1, F2 ... FX keys are disabled and act like Fn+F1, Fn+F2 ... To enable the keys and make use of Fn+FX, modify /etc/pommed.conf by changing fnmode = 1 to fnmode = 2 and restart pommed with /etc/init.d/pommed restart.

Backlight also works using frankie's backlight, that can be controlled with macbook-backlight-control.

To enable the sound keys (Fn+F3, Fn+F4 and Fn+F5), you have to modify /etc/pommed.conf : change init = -1 to init = 80 and (at least on Macbook 2) change volume = "PCM" to volume = "Front" and after that restart pommed with /etc/init.d/pommed restart. (Are you sure? I've set it to PCM. If so please explain why)

Video

Video now works automatically withour manually installing 915resolution.

Configure highres video playback

For highres video playback something like the following is needed in the Device section:

        Option          "LinearAlloc" "6144"
        Option          "CacheLines" "1080"

External monitor

Note when using an external display: unless the display resolution is in the small builtin supported list (it won't be if it's widescreen or highres) then you may need to use 915resolution to set a mode for the external display.

Note when using multiple displays: the order for ?MonitorLayout is "pipe a, pipe b" but this corresponds to "screen 1, screen 0", not "screen 0, screen 1" as you might expect (and isn't documented in the man page...)

You need a mini-DVI/VGA adaptor.

Configure dual screen

Dual screen configuration for etch does not work for xorg 7.2 and later on lenny. Just use the usual single-screen xorg.conf, and configure output later.

You can control X with xrandr.

LVDS is the liquid display, VGA is the external output. (see output of xrandr command)

To enable dual screen

xrandr --output VGA --mode 1024x768
xrandr --output VGA --right-of LVDS

or in one big command including handling of disabling unneeded output:

xrandr --output TMDS-1 --off  --output LVDS --mode 1280x800 --crtc 1 --output VGA --mode 800x600  --right-of LVDS --crtc 0

You also need to set 'Virtual' the get the most out of you hardare, this is the overall space you have to work with in your screens. The intel driver supports a max of 2048x2048 before turning off DRI. I dont thik you can chnage this while X is running so xrandr won't be able to make use the extra space until x is restarted. If you have a wide screen already, I suggest setting up the macbook below the screen as you can then fit a 1920x1200 monitor.

Section "Screen"
        Identifier      "Default Screen"
        SubSection      "Display"
                Virtual 2048 2048
        EndSubSection
EndSection

To disable dual screen, simply specify VGA to off

xrandr --output VGA --off

Color Profile

You can use the Color Profile from Mac OS X. Copy *.icc from /Library/ColorSync/Profiles/Displays/.

Install xcalib and enable the Color Profile:

xcalib ColorProfile.icc

Alternatively, install argyll and enable the Color Profile:

dispwin ColorProfile.icc

Xcalib has more flexible options to e.g. inverse screen or setup night vision, whereas dispwin supports xrandr so can calibrate secondary screen.

Sound

{i} This is written under linux-image-2.6.26-1-amd64 @ version=2.6.26-2 as of 2008-080-17 for lenny.

It works out of box with ALSA after disabling mute.

In case you have trouble, reconfigure sound system with "dpkg-reconfigure linux-sound-base" to use ALSA. Then udev system picks snd_hda_intel and required modules with proper parameters at boot time.

Please note Surround output is connected to speaker via headphone plug. Neither Center nor Front are connected. You need to customize mixer default to unmute Surround to hear sound and optionally maximize its volume for ease of use. (You can do this via alsamixer or gnome volume control. For gnome volume control, you need to customize it to get menu for surround enabled.)

For MacBook Aluminum (late 2008)

Wireless

Different ?MacBooks use different WiFi cards – in some more recent kernels, WiFi will work out-of-the-box; in other cases, it requires more hacking.

Keyboard

After the standard installation of Debian Linux, what you type on the keyboard might not be what you see on the screen, and some characters, such as curly brackets, might not be available at all. This is due to an incorrect keyboard mapping. In particular you might want to add/change/configure the following:

Swapped keys: Even if you have chosen the correct general keyboard layout, e.g. German for a German keyboard, there may still be keys swapped, e.g. you press the '<' key and get a '^' and vice versa. This can be corrected with a global option.

Alt-Gr: Alt-Gr stands for 'alternate graphic' and is a modifier key, much like Shift or Ctrl, used to type special characters, typically the 'third symbol' on the lower right of a key. The Mac keyboard does not have such a key, so we want to configure the right Apple key as an Alt-Gr key.

Function keys: You may also want to configure the function keys.

The keyboard mappings are configured separately for the X11 (X Window) system and for the consoles.

X11 (X Window)

The recommended place to configure the keyboard mapping for X11 is the configuration file /etc/X11/xorg.conf, which has the advantage of effecting all users. Each user can also configure his/her keyboard individually in the (Gnome) Desktop Preferences.

/etc/X11/xorg.conf:

To set options for the keyboard you can use the XkbOptions field in the keyboard section of file /etc/X11/xorg.conf. To activate the right Apple key as an Alt-Gr key add "lv3:rwin_switch". To correct the swapped keys add "apple:badmap". To do both combine them with a separating comma, as shown below.

Section "InputDevice"
        Identifier      "Generic Keyboard"
        Driver          "kbd"
        Option          "CoreKeyboard"
        Option          "XkbRules"      "xorg"
        Option          "XkbModel"      "pc105"
        Option          "XkbLayout"     "it"
        Option          "XkbOptions"    "lv3:rwin_switch,apple:badmap"
EndSection

To activate the changes restart X11 by pressing Ctrl-Alt-Backspace, but close all sensitive applications first.

Remark by some other author: Instead of "it" (Italian layout), you might want to choose your layout). Also, more important, I had to insert:

Section "InputDevice"
        ...             ...             ...
        Option          "XkbVariant"    "mac"
        ...             ...             ...
EndSection

Desktop Preferences:

It is probably best to change the keyboard mappings discussed here centrally in /etc/X11/xorg.conf. However, it is also possible to change them in the Desktop Preferences. For Gnome click 'Desktop' -> 'Preferences' -> 'Keyboard'.

For the basic keyboard definition go to 'Layouts'. As 'keyboard model' choose '?MacBook/MacBook Pro (Intl)' (although 'Generic 105-key (Intl) PC' seems to work fine as well). As 'selected layout' add and make default 'Germany' -> 'Macintosh' or 'Macintosh, eliminate dead keys' (although 'Germany Eliminate dead keys' seems to work fine as well).

For the configurations under discussion here go to 'Layout Options'. To configure the right Apple key as an Alt-Gr key select 'Third level choosers' -> 'Press Right Win-key to choose 3rd level.'. To correct the swapped keys select 'Miscellaneous compatibility options' -> 'Swap keycodes of two keys when Mac keyboards are misdetected by kernel.'.

When I did this I actually got obscure error messages. So this seems to be buggy and I would not recommend it also for this reason.

<!> For squeeze users, xorg has changed the way they handle the keyboard settings. There is a unified config file for xorg and console keyboard settings (xorg.conf keyboard entry will be ignored in most cases). Therefore, you should try to edit the file /etc/default/keyboard. For example, when using a french mac layout, the file should look like this:

XKBMODEL="pc105"
XKBLAYOUT="fr"
XKBVARIANT="mac"
XKBOPTIONS="lv3:rwin_switch"

More Over, level 3 switch might not work currently, due to bug 531771. You can circumvent it by replacing /usr/share/X11/xkb/symbols/pc with this file (be aware that an update of the xkb-data package might erase your changes, so having a backup might help).

Consoles

To configure the right Apple key as an Alt-Gr key for the consoles (the black and white screen you get with Ctrl-Alt-F1 etc.) add the following line to /etc/console-tools/remap.

s/keycode 126 =/keycode 126 = AltGr/;

Correcting swapped keys should also be possible, but I have not figured out how to do that yet.

To set up the correct keyboard mappings in the console do:

dpkg-reconfigure -p low console-data

and select "Select keymap from the full list" and then select "pc / qwerty / British / Apple USB / Standard" (or whatever country you prefer).

Fn-key behaviour

If you want to change the bahaviour of the Fn-keys look at /etc/pommed.conf after you've installed pommed on lenny. (Or look at the parameters of the hid kernel module.)

Has anyone made the fn key work? --> Yes, on ?MacBook2,1(osamu) with current stable (lenny, 2.6.26). The use of pommed program as written above makes it work better.

Other issues

Screenshots:

Alternatively you can work around this with xmodmap and xkbset for missing keys and mouse clicks. xkbset is useful for emulating mouse buttons with the keyboard.

xmodmap -e "keycode 115 = Alt_L"           # left-apple
xmodmap -e "keycode 116 = Zenkaku_Hankaku" # right-apple
xmodmap -e "keycode 108 = Pointer_Button3 Pointer_Button2" # KP-ENTER
xkbset m

379789 has been filed to track down a problem with keymap

{i} See below "Mouse 2nd and 3rd buttons" for mouse click emulation and fixing unresponseve Keypad equal in num lock mode.

To work around issues of missing/unresponsive keys on the MacBook Japanese models with older Linux kernel, see MacBookJp for helpful scripts (Japanese page but scripts are in English). This problem has been fixed in Debian kernel 2.6.24-1-amd64 for sid (as of Feb 4, 2008). If the patch is present the kernel outputs a message: "Fixing up MacBook JIS keyboard report descriptor".

Synaptics Touchpad

The touchpad is made by Synaptics, and should work out of the box. However, you may wish to configure it in various ways, notably:

The easiest way to configure the touchpad (in lenny) is using gsynaptics (Note: plural!), which provides a GNOME interface to configuration. In squeeze, this is replaced by gpointing-device-settings.

Configuration can be found (once the package is installed) in the menu at:

Using gsynaptics requires adding one line to /etc/X11/xorg.conf as follows. Add the line:

        Option          "SHMConfig"             "true"

to the Synaptics Touchpad section. For example, the following section works:

Section "InputDevice"
        Identifier      "Synaptics Touchpad"
        Driver          "synaptics"
        Option          "SendCoreEvents"        "true"
        Option          "Device"                "/dev/input/mice"
        Option          "SHMConfig"             "true"
EndSection

You should now be able to use the configuration dialog.

Remark by some other author: For me, this did not work. I had to insert one extra line, see below:

Section "InputDevice"
        ...             ...                     ...
        Driver          "synaptics"
        Option          "CorePointer"           "true"
        Option          "SendCoreEvents"        "true"
        ...             ...                     ...
EndSection

SHMConfig is turned off because it is a security hole (a malicious user can track and control your pointer); see mjg59: Why SHMConfig is off by default. Alternatives to using SHMConfig now exist (using xinput), but are not (to my knowledge) supported by a GNOME GUI.

Alternatively, you can manually configure the touchpad by editing /etc/X11/xorg.conf as described below. This is documented in the synaptics(5) man page, which is accessible by typing:

man 5 synaptics

For reference, see also:

Basic configuration

<!> Addition of "Section "ServerLayout"" to /etc/X11/xorg.conf is important to get "SHMConfig" enabled properly by enabling Synaptics Touchpad.

The following basic /etc/X11/xorg.conf will enable your touchpad in a sane mode under normal lenny. I mean no more accidental clicks by touching it but you can move pointer and scroll browser vertically.

# xorg.conf (X.Org X Window System server configuration file)

Section "ServerLayout"
    Identifier     "Simple Layout"
    InputDevice    "Generic Keyboard" "CoreKeyboard"
    InputDevice    "Synaptics Touchpad" "CorePointer"
    InputDevice    "Configured Mouse" "SendCoreEvents"
    Screen         "Default Screen" 0 0
EndSection

Section "InputDevice"
        Identifier      "Generic Keyboard"
        Driver          "kbd"
        Option          "XkbRules"      "xorg"
        Option          "XkbModel"      "jp106"
        Option          "XkbLayout"     "jp"
EndSection

Section "InputDevice"
        Identifier      "Synaptics Touchpad"
        Driver          "synaptics"
        Option          "SendCoreEvents"        "true"
        Option          "Device"                "/dev/input/mice"
        Option          "SHMConfig"             "true"
        Option          "MaxTapTime"            "0"
        Option          "HorizScrollDelta"      "0"
        Option          "VertScrollDelta"       "30"
        Option          "TapButton1"            "0"
        Option          "TapButton2"            "0"
        Option          "TapButton3"            "0"
EndSection

# In case you have USB mouse
Section "InputDevice"
        Identifier      "Configured Mouse"
        Driver          "mouse"
EndSection


Section "Device"
        Identifier      "Configured Video Device"
EndSection

Section "Monitor"
        Identifier      "Configured Monitor"
EndSection

Section "Screen"
        Identifier      "Default Screen"
        Monitor         "Configured Monitor"
EndSection

<!> Section "?InputDevice" with "Generic Keyboard" should be adjusted to your original localized configuration of xorg.conf generated by "sudo dpkg-reconfigure -phigh xserver-xorg". This example is for Japanese system.

You can configure your touch pad by installing "gsynaptics" package or similar. Under GNOME, you can access it from "System" -> "Preferences" -> "Touchpad".

{i} If you insist to have "tap to click" feature enabled but wish to prevent accidental taps while you're typing, it is advisable to run syndaemon after starting X with something like following command:

 $ syndaemon -i 2 -t -d 

As for missing mouse butons, see "Mouse 2nd and 3rd buttons". (I found relying on taps can get quite annoying. See below if you wish.)

Mouse 2nd and 3rd buttons

X level emulation for lenny

Left Apple key (keycode = 115, sometimes called left command key) may be used as replacements for mouse 2nd and 3rd buttons.

This can be done by including following code in the ~/.xsessionrc start up script of your home directory as:

/usr/local/bin/mousekeys &

and create startup script /usr/local/bin/mousekeys as:

# wait for some program, here gnome-panel
until ps -C gnome-panel >/dev/null; do sleep 1 ; done
# set xmodmap, DEL is Fn-Delete, BS is Delete
xmodmap - << EOF >/dev/null 2>/dev/null
keycode 115 = Pointer_Button3 Pointer_Button2
keycode 157 = KP_Equal
keycode  19 = 0 parenright 0 Scroll_Lock
keycode 215 = Print Sys_Req
keycode 216 = Insert
keycode 217 = Pause Break
EOF

This binds these keys to mouse keys and some missing keys. (You may execute these from X terminal emulators too.)

<!> Redifinition of "keycode 19" for normal "0" key is for Japanese keyboard. Please adjust these key redifinitions as you like.

For GNOME, enable mouse keys by keyboard from "System" -> "Preferences" -> "Keyboard" -> "Mouse Keys" -> "Allow to control the pointer using keyboard" : "check to enable".

Alternatively, you may use "xkbset m" command by installing the xkbset pacakage.

Alternatively, you can use Fn-F8(keycode = 215), Fn-F9(keycode = 216), and Fn-F10(keycode = 217) keys on system without keyboad light with:

xmodmap - << EOF
keycode 215 = Pointer_Button1
keycode 216 = Pointer_Button2
keycode 217 = Pointer_Button3
EOF

If you would like to use other keys, here's how to do it:

Instead of using generic X startup code via ~/.xsessionrc, you may set it up via GNOME specific startup method: "System" -> "Preferences" -> "Sessions" -> "Startup programs" -> "Add" -> ...

<!> It is not wise to use ~/.xsession to add small X startup code since this requires you to create the full X startup code.

<!> "sleep" command in the startup script "/usr/local/bin/mousekeys" was needed to avoid running "xmodmap" command too early. Otherwise, I do not see "xmodmap -pke" reflecting changes. Somehow, mouse keys only were working and regular key redifinitions were not working.

Kernel level emulation

<!> This needs to be verified. (osamu, based on debian-jp ML) Under new X system of recent Ubuntu jaunty and Debian squeeze, this may be your only option.

Recent kernel comea with "?DeviceDrivers - Macintosh device drivers - Support for mouse button 2+3 emulation" enabled: CONFIG_MAC_EMUMOUSEBTN=y

Following entries in /etc/sysctl.conf can enable Kernel level mouse button 2+3 emulation:

dev.mac_hid.mouse_button_emulation = 1
dev.mac_hid.mouse_button2_keycode = 116
dev.mac_hid.mouse_button3_keycode = 108

{i} You may run each of these lines as an argument to "sysctl -w", but without the spaces. Example sysctl -w dev.mac_hid.mouse_button_emulation=1

{i} Here, "keycode = 116" is "Super_R" (Right-Apple) and "keycode = 108" is "KP_Enter" on US keyboard.

{i} Alternatively, you may pick "keycode = 115" for "Super_L" (Left-Apple) and "keycode = 209" for "Hiragana_Katakana" on JPN keyboard.

Touchpad for the new 2008 unibody Macbook and Macbook Pro

Note: this infomation is too old. bcm5974 is already in to Linux kernel from 2.6.27.

The new unibody MacBook Pro requires a new touchpad driver to work. This is discussed over at Ubuntu (http://ubuntuforums.org/showthread.php?t=840040). The driver bcm5974.ko is available here http://bitmath.org/code/bcm5974-dkms/. The snag is that there is no deb and installation is via the DKMS system (http://linux.dell.com/dkms/). But I managed it, so you almost certainly can.

First install git.

# aptitude install git-core

Then download the latest source for the bcm5974 driver and the usbhid module, which you also need.

$ git clone http://bitmath.org/git/bcm5974-dkms.git
 ...
$ git clone http://bitmath.org/git/usbhid-dkms.git
 ...

You'll need to download the dkms too. I used the ubuntu deb at http://linux.dell.com/dkms/

# dpkg -i dkms_2.0.20.4-0ubuntu1_all.deb

Then build a deb of the bcm5974 driver.

$ cd bcm5974-dkms/

Follow the instructions in the HACKING file, but not until the end.

$ make bump

You'll need debhelper and dpkg-dev installed to make the deb.

# dpkg-buildpackage
# cd ..

This makes the deb. Make the deb for the usbhid module.

$ cd usbhid-dkms/
$ make bump
$ dpkg-buildpackage
cd ..

Now you should have two packages which you can install. dpkg uses dkms to make the modules.

# dpkg -i bcm5974-dkms_1.1.1_all.deb usbhid-dkms_0.11.1_all.deb
# modprobe bcm5974

This should install and load the module. Now all you need is to edit xorg.conf.

xorg.conf:

Section "Module"
   Load    "glx"
   Load    "synaptics"
EndSection

Section "InputDevice"
   Identifier      "Generic Keyboard"
   Driver          "kbd"
   Option          "CoreKeyboard"
   Option          "XkbRules"      "xorg"
   Option          "XkbModel"      "pc105"
   Option          "XkbLayout"     "gb"
   Option          "XkbOptions"    "lv3:rwin_switch,apple:badmap"
EndSection

Section "InputDevice"

   Identifier      "Synaptics Touchpad" Driver  "synaptics"
   Option  "SendCoreEvents"        "true"
   Option  "Device"                "/dev/input/mice"
   Option  "Protocol"              "auto-dev"
   Option  "SHMConfig"             "true"
   Option  "New AccelFactor"       "0.03"
   Option  "LeftEdge"              "0"
   Option  "RightEdge"             "1280"
   Option  "RightEdge"             "1280"
   Option  "TopEdge"               "0"
   Option  "BottomEdge"            "800"
   Option  "MinSpeed"              "0.94"
   Option  "MaxSpeed"              "1"
   Option  "AccelFactor"           "0.0015"
#tapping

   Option  "RTCornerButton"        "2"
   Option  "RBCornerButton"        "3"
   Option  "LTCornerButton"        "2"
   Option  "LBCornerButton"        "3"
   Option  "FingerHigh"            "30"
   Option  "FingerLow"             "20"
   Option  "MaxTapTime"            "150"
   Option  "FastTaps"              "0"
   Option  "TapButton1"            "1"
   Option  "TapButton2"            "2"
   Option  "TapButton3"            "3"
#edge scroll

   Option  "VertEdgeScroll"        "0"
   Option  "HorizEdgeScroll"       "0"
   Option  "VertScrollDelta"       "5"
   Option  "HorizScrollDelta"      "0"
#two finger scroll

   Option  "VertTwoFingerScroll"   "1"
   Option  "HorizTwoFingerScroll"  "1"
EndSection

Section "Device"
   Identifier      "Configured Video Device"
   Driver "nvidia"
EndSection

Section "Monitor"
   Identifier      "Configured Monitor"
EndSection

Section "Screen"
   Identifier      "Default Screen"
   Monitor "Configured Monitor"
EndSection

Section "ServerLayout"
   Identifier "Main Layout"
   Screen "Default Screen"
   InputDevice "Synaptics Touchpad"
   InputDevice "Generic Keyboard"
EndSection

This set up gives you tapping 1, 2, or 3 fingers for left, middle, and right clicks and two-finger scrolling.

Processor

CPU frequency scaling

CPU frequency scaling in kernel (basics)

CPU frequency scaling is governed by SPEEDSTEP_CENTRINO kernel module. You should also enable the acpi_cpufreq module and one of its methods cpufreq_ondemand or cpufreq_conservative.

echo speedstep_centrino >> /etc/modules
echo acpi_cpufreq >> /etc/modules
echo cpufreq_ondemand >> /etc/modules

Here, I chose the cpufreq_ondemand for responsiveness.

CPU frequency scaling in kernel (customization)

<!> For lenny, these do not seem to be needed anymore.

To avoid unnecessary overhead you can let kernel scale the CPU frequency automatically. Just load module cpufreq_ondemand or cpufreq_conservative. The ondemand-module is perhaps better choice if you want the system to be as responsive as possible.

Next add this to /etc/rc.local or to another startup script:

# Switch on "ondemand" CPUfreq governor
# This is more reliable and faster than using userspace governor and
# a userspace program to control CPU frequency.
# You have to do this for each CPU.
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo ondemand > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
# The "ondemand" governor in kernels prior to 2.6.22 something tend to
# have a bit high sampling rate, so we will modify it according to
# http://www.linuxpowertop.org/known.php
# This is not _required_, but reduces the amount of wake-up calls the
# processor makes each second
cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate_max > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
cat /sys/devices/system/cpu/cpu1/cpufreq/ondemand/sampling_rate_max > /sys/devices/system/cpu/cpu1/cpufreq/ondemand/sampling_rate

CPU frequency scaling in userspace

In case you want more complex CPU frequency scaling schemes, you can just load the module cpufreq_userspace, set it as default (see above) install powernowd or cpufreqd package for CPU frequency scaling. There are several other daemons available, but those two work quite well.

You can use gkfreq to monitor the CPU frequency in gkrellm (currently it only supports one processor but can be easily modified to support 2 cores - I have send a small patch to the maintainer) : http://www.peakunix.net/gkfreq/

CPU throttling

CPU throttling means forcing the processor(s) to idle for a certain amount of their time. When processor is not heavily loaded this saves battery but also slows the processor down. With 1st generation Macbook switching both cores to 50% throttling so that they are idle 50% of the time can give maybe 30-40 minutes of extra battery life. The Macbook is perfectly usable even both processors are running at 1Ghz (scaled down) and throttled to 50%. So in most cases, it's a good idea to use CPU throttling when using battery.

There are various ways to enable CPU throttling. It is probably easiest to use laptop-mode, and make sure that throttling is enabled in /etc/laptop-mode/laptop-mode.conf:

# Should laptop mode tools control the CPU throttling? This is only useful
# on processors that don't have frequency scaling.
# (Only works when you have /proc/acpi/processor/CPU*/throttling.)
CONTROL_CPU_THROTTLING=1
# Legal values are "maximum" for the maximum (slowest) throttling level,
# "minimum" for minimum (fastest) throttling level, "medium" for a value
# somewhere in the middle (this is usually 50% for P4s), or any value listed
# in /proc/acpi/processor/CPU*/throttling. Be careful when using "maximum":
# this may be _very_ slow (in fact, with P4s it slows down the processor
# by a factor 8).
BATT_CPU_THROTTLING=medium
LM_AC_CPU_THROTTLING=minimum
NOLM_AC_CPU_THROTTLING=minimum

Powertop

If you are serious about saving power, take a look at Powertop program. It is a very good interactive program that gives suggestions on how to minimize CPU wakeups. I was able to drop wakeups from around 1500 to roughly 400 with the aid of this program.

With up-to-date lenny/sid, it's possible to drop to around 100 wakeups (with wifi and compiz).

Infrared Receiver

Infrared receiver on MacBook is an HID device. For lenny,

Install them and follow their instruction.

iSight

Although linux kernel supports the iSight device with linux-uvc driver, sometimes the iSight device on (older Tiger ?) ?MacBooks requires firmware binary blob to be loaded while it is intialized.

Here is the method to extract required firmware blob from MacOS Tiger partition. Please note MacOS Finder will not see these files.

Locate the firmware from MacOS X terminal console shell or Linux, and note the location, you will need this later:

# mkdir -p /MacOSX
# mount -t hfsplus /dev/sda2 /MacOSX
# ls /MacOSX/System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBVideoSupport.kext/Contents/MacOS/AppleUSBVideoSupport

Note firmware driver from MacOS X 10.6 (Snow Leopard) may not work with isight-firmware-tools.

Now we install the needed packages:

# aptitude install module-assistant linux-uvc-source isight-firmware-tools

When installing isight-firmware-tools, debconf asks about the path to the firmware. Specify the location you have found above. For squeeze, neither module-assistant nor linux-uvc-source are needed since it uses linux-image-2.6.32-5.

Once the source and tools are installed, you should have /lib/firmware/isight.fw . If not, something went wrong installing isight-firmware-tools.

To try to extract the firmware again (only do this if you don't have /lib/firmware/isight.fw ) :

# dpkg-reconfigure -plow isight-firmware-tools

Keep repeating this until you get the /lib/firmware/isight.fw .

# modprobe uvcvideo
# /etc/init.d/hal restart

Test it with Cheese.

# aptitude install cheese
$ cheese

If you see your face, iSight is probably working :).

If it could not detect the iSight, shutdown and start Mac again (not by rebooting). Also check V4L related information.

Support of SMC

SMC means System Management Controller.

The gentoo wiki suggests loading the "applesmc" module, which works fine for me (albertl7). Among other things, t allows me to control the medium fan speed, which I increase because my Macbook gets so hot. I put this is rc.local:

echo "4000" > /sys/devices/platform/applesmc.768/fan1_min

The gentoo wiki has a different path, so it might be different on all the various Macbook computers. The higher fan speed makes more noise, but I'm comfortable with that.

There are a few packages available over the Internet to control the fan(s) speed depending on the temperature reported by the various hardware sensors, for instance macfanctld. Binaries (which may or may not work on Debian) can be downloaded from https://launchpad.net/~mactel-support/+archive/ppa.

Direct EFI Boot support

CONFIG_FB_IMAC support is for booting from ELILO (EFI). You are most probably using lilo/rEFIt to boot, using IMAC driver will make your screen appear scrambled. Use CONFIG_FB_I810 driver instead.

CPU Core Temperature Sensor

Model-specific register (MSR) can be used access CPU temperature sensor. You can use many standard applets to display temperature on lenny.

See also

* MacBook/Legacy – dated but still at times informative tips for older Debian and kernel versions

Resources

Primary resources

Mactel-Linux has mactel specific kernel patch and hardware tool resource. Its subversion archive can be seen at http://svn.sourceforge.net/viewvc/mactel-linux by the browser or retrieved by:

 $ svn co https://mactel-linux.svn.sourceforge.net/svnroot/mactel-linux mactel-linux

Helpful guide on compiling a mactel kernel: http://gentoo-wiki.com/HARDWARE_Apple_MacBook

Secondary resources



CategoryDeveloper