Gentoo Wiki ArchivesGentoo Wiki

Apple_MacBook/Talk_Overflow

Contents

Kernel patching

I tried to apply the mactel-patchset to a vanilla-sources, which failed in version.patch, its looking for a /usr/src/linux/Makefile for 2.6.17 (Crazed Snow-Weasel) and 2.6.18 is (Avast! A bilge rat!). I deleted version.patch and it applied. Does mactel-patchset need to be fixed for a vanilla-sources-2.6.18?

(updated) UGH! it says to remove version.patch :-) Ill try reading it... better..

CFLAGS

The Prescott is a Pentium 4 cpu, whereas the Core Duo is based off the Pentium-M which is actually a re-vamped Pentium 3. In essence, the Core Duo is a P3 with SSE2 and SSE3 support. The closest GCC match is "prescott" simply because it supports all these (from GCC manual, "prescott - Improved version of Intel Pentium4 CPU with MMX, SSE, SSE2 and SSE3 instruction set support."). However the system will then be optimised for a P4, which the Core Duo is not. Maybe we are better off using "-march=pentium3 -msse2 -msse3" or "-march=pentium-m -msse3"? (Afterall, we don't use "pentium4" for a "pentium-m" system, even though they support the same instruction sets.) --Chris

You're right that the Core Duo is based on the Pentium-M microarch, but it's had some major updates done to it. Fex, the SSE front and backend are completely redone. On the P-M, it took twice as long to decode SSE than X87. Core can handle up to three packed and micro-op SSE instructions at once, making using SSE the advantage. However, when you set -march=pentium-m, GCC prefers to generate x87 instructions. There's other changes that make Core more similar to Netburst than P-M when it comes to cost calculation, prefetch block size, etc., all of which are dependent on -march. Check out gcc/config/i386/i386.c and the IA32 Intel Architecture Optimization Reference Manual. -qed([1])

It is indicated by "pni" in /proc/cpuinfo.


MAKEOPTS

(gaubenhans@hotmail.com has the impression it is)

make clean; time make -j1

real    7m1.067s
user    6m29.017s
sys     0m34.949s

make clean; time make -j2

real    3m58.850s
user    6m41.904s
sys     0m34.806s

make clean; time make -j3

real    3m54.615s
user    6m43.332s
sys     0m36.128s

make clean; time make -j4

real    3m53.045s
user    6m44.173s
sys     0m36.167s

(Note: I had problems compiling some packages with -j3 and gcc-4.1.1, like wesnoth, wxgtk or blender. I haven't had problems with -j1, I don't know with others values.)

- Compiled wesnoth successfully with make.conf in MacBook Configuration Files.

INPUT_DEVICES

For MacBooks:

INPUT_DEVICES="keyboard mouse synaptics evdev"

I dont know if that also is the right choice for MacBook Pros but i think so.

Works fine on my 15" 2.33GHz Core 2 Duo MacBook Pro --24.27.151.212

Kernel

Kernel .config

blscreen generously provides a working kernel config, so this should be easy. Take this only as a starting point for an optimal configuration, you might be interested in additional/different options.

1. Get the config

 cd /usr/src/linux
 wget -O config-macbook-blscreen http://omnibus.uni-freiburg.de/~s8rasand/config
 cp config-macbook-blscreen .config
 make oldconfig # just in case

2. This config should work out of the box. It is not recommended to fiddle with it at this point.


Note 1:If you need reiserfs support you should execute 'make menuconfig' and add it. I had no problems with this -- Well.Caffeinated

Note 2:I had to enable LED devices to resolve a dependency from CONFIG_SENSORS_APPLESMC -- tucolino:

 #
 # LED devices
 #
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y

Note 3:If you reinstall OS X in order to have more/larger partitions you will (probably) have to disable the EFI support in the Kernel.

Note 4: If you get:

Kernel panic - not syncing: IO-APIC + timer doesn't work! Boot with apic=debug and send a report. Then try booting with the 'noapic' option

Previously I thought, that this can be solved by setting the "Timer frequency" in "Processor type and features" either to 100 or 1000 Hz. But after a long time of not getting this message, I got it once after I wrote it. So setting the timer frequency to 1000 doesn't completely solve this problem, but it has reduced it for me.

-- I think a better solution is to set the kernel boot parameters lpj=7330000 (for 1.83 ghz macbook pro) or lpj=8000000 (for the 2.0 ghz macbook pro). See https://help.ubuntu.com/community/MacBook

--- Concurred. Add lpj=??????? to the end of the kernel line in /boot/grub/menu.lst --Dirk R. Gently 09:06, 7 March 2007 (UTC)

Note 5: recent MBPs also require the SKY2 ethernet driver:

 #
 # Ethernet (1000 Mbit)
 #
 CONFIG_SKY2=m

Note 6:The config does not have INOTIFY set, this is something most users would want.

Note 7I had to deactivate EFI Support in the kernel in order to have the kernel boot my root partition!

Note: I moved blscreens Kernel .config to the Talk Section along with all the notes that went with it.
Kernel panic - not syncing: IO-APIC + timer doesn't work! Boot with apic=debug and send a report. Then try booting with the 'noapic' option

Question: Where is problem? I get this message with rt-kernel just only with 1000 Hz - if I have 100 or 250 every thing was OK. Do you know why?

I don't know why you made different experiences. Probably you have a MacBook and I a MacBook Pro or different revisions? I also think, there must be a very little number of people world wide with this problem. Cause, if you search the internet, you only find very few reports of this problem. Probably a chip set or mainboard bug of early versions of the MacBook. My MacBook Pro currently gets a new logic board cause of the high frequent noise at low cpu usage. Maybe the kernel panic problem is gone with the new board. --ChristophMueller 13:28, 28 January 2007 (UTC)

My MacBook Pro is back with a new Logic Board. I updated the Kernel to 2.6.20 and have it configured with 1000Hz. I didn't added "lpj" to the kernel params. I never got this error again. I also don't get the "Can't find root partition" error anymore, that occured from time to time while booting my MacBook Pro. But I can't say, if it was fixed with the new Logic Board, or with the new Kernel. --ChristophMueller 16:46, 22 April 2007 (UTC)

I had an issue at boot time where the terminal would appear all wonky and scrambled (gentoo-sources-2.6.19-r7 and gentoo-sources-2.6.18 w/ blscreen's provided config. Yes, I know these aren't "known working" kernels) until some later point in the bootup process (before I got to the login prompt). This wasn't a problem for 2.6.18 since it would make it that far, but I was trying to debug 2.6.19 and it was oops-ing before the screen fixed itself. After hitting #gentoo on freenode and getting suggestions that I should turn off framebuffer support in the kernel, I went back and checked, guessing that framebuffer support was probably not enabled. After turning framebuffer support on and fiddling with the boot time kernel args for that I got the screen to display correctly (native res too, as far as I can tell). EDIT: This is on a MacBook (black) Core 2 Duo 32-bit install

--Bad code 00:58, 15 March 2007 (UTC)

I think I've got a working config file for the latest kernel in the stable tree (2.6.19-r5 gentoo). I pulled blscreen's config, added framebuffer and sata driver support, as well as iptables. File hosted here for the time being: http://mason.gmu.edu/~bhroleno/config-2.6.19-gentoo-r5

--Bad code 00:58, 15 March 2007 (UTC)

MacTel Patches

I got almost everything working, i.e. a normal bog-standard laptop, with gentoo-sources-2.6.18, maybe use the default kernel to get you off the liveCD and do the extra Apple tweaks later at your leisure from your nice graphical environment.

Note: as of 06.09.2006 you need to remove 'efi_e820_all_mapped_fix.patch' and 'version.patch' before running the apply command if you use kernel 2.6.18-rc6. --Otho 22:44, 25 October 2006 (UTC) These two files are now already removed in the repository. You may also consider not to use sigmatel_audio.patch (see section "Sound").

Note: usbhid.patch didn't work for some reason. I had to apply the contents manually. Something about POWERBOOK_ISO_KEYBOARD seems to be different? -- seto 84.226.57.50 18:09, 22 November 2006 (UTC)

< Grub 0.97-r2

Using Grub 0.97-r2 or earlier is now possible thanks to a patch. You will have to sort of compile grub manually (but with the help of ebuild). If you run stable add sys-boot/grub to /etc/portage/package.keywords this will give you grub-0.97 whatever (currently -r2). Then do the following:

emerge -f grub
ebuild /usr/portage/sys-boot/grub/grub-0.97-r2.ebuild digest
ebuild /usr/portage/sys-boot/grub/grub-0.97-r2.ebuild unpack
cd /var/tmp/portage/grub-0.97-r2/work/
wget http://www.scl.ameslab.gov/Projects/mini-xen/grub-a20.patch
patch -p0 < grub-a20.patch
ebuild /usr/portage/sys-boot/grub/grub-0.97-r2.ebuild compile
ebuild /usr/portage/sys-boot/grub/grub-0.97-r2.ebuild install
ebuild /usr/portage/sys-boot/grub/grub-0.97-r2.ebuild qmerge

Now you setup grub.conf like in the handbook, then do the following (modifying if on a different partition):

grub
root (hd0,2)
setup (hd0,2)
quit

You should see mostly good results except it will fail on embeding stage1_5, but as it points out it is ok. Now if your partition is not already flagged bootable then you will need to use fdisk to do that:

fdisk /dev/sda
a
3
w

Note: When you reboot and rEFIt comes up you need to select the Linux on Partition 3 Nnutter 08:55, 21 June 2006 (UTC)

Checking the New System Out

Install rEFIt After Installtion:

Use this one with care! The better way is to install rEFIt BEFORE the installation. Installing it afterwards may break your system!

Reboot into OS X and install rEFIt as detailed in the OnMac.net guide. If everything was successful, you should have a convenient boot menu from which to select OS X and Linux (and Windows too, if you also installed that). Congratulations! Now you can start doing some real work in Gentoo.

This broke on my system. I had to boot from the MacOS InstallCD and reset booting to hard drive macosx. It seems wiser to install rEFIt prior to rebooting and install linux/windows. Can anyone with an untouched mac confirm that rEFIt prior to Linux install works correctly? - Yes I installed rEFIt prior to Linux on the white macbook and it worked fine.

When I did this and my mac wouldn't boot I just zapped the pram once (press command (aka apple) + option + P + R when you start your mac and hold until you hear it chime)

The OnMac.net Ubuntu guide does install rEFIt first. Installing it first does work on a Macbook.

Adding to and Configuring the New System

Sound

Presumably for kernels prior to 2.6.20:

If you apply this patch to your kernel, sound will come out the speakers. The only disadvantage is that when the head phones are plugged in, sound will continue to come out the speakers.Alsa Patch.... Alternate

Note: (If you have it compiled in the kernel like above you don't need alsa drivers.) With recent alsa drivers (verified is alsa-driver-1.0.12) sound just works as expected. No patch necessary, no need to plug headphones into line-in, when they are plugged in the internal speakers are quiet. The sigmatel_audio.patch seemed to impair this behaviour, so I did not apply it. Blscreen 03:54, 13 September 2006 (UTC)

Desktop Setup

Setting up X11

Using X11-drm

1a) Add the entries VIDEO_CARDS="i810 vesa" and INPUT_DEVICES="keyboard mouse synaptics evdev" to your /etc/make.conf.

1b) Compile your kernel with DRM support DISABLED

 Processor type and features --->
 <*> MTRR (Memory Type Range Register) support
 Device Drivers  ---> 
   Character devices  ---> 
 <M> /dev/agpgart (AGP Support)
 [M] Intel 440LX/BX/GX and I815/I820/I830M/I830MP/I840/I845/I850/I860 support
 (Enable your chipset instead of the above.)
 < > Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)

1c) Add the following modules to your /etc/modules.autoload.d/kernel-2.6

 intel-agp
 i810
 i915

1d) Emerge x11-drm and then do the following

 eselect opengl set xorg-x11

Note: emerge x11-drm will fail for kernel version 2.6.19. - Turdus 15-12-2006

Debian admin xorg.cong (old) The Debian xorg.conf I moved because it failed to work for me. --Dirk R. Gently 23:09, 2 April 2007 (UTC)

915 Resolution

915resolution is a hack for 800/900 series Intel chipsets. It replaces one of the video modes (namely, one you do not need) with another of your choice. In this case, you want to add your Macbook's native resolution of 1280x800 (because it's pretty). After

emerge 915resolution

You should edit your /etc/conf.d/915resolution to something like this, according to the instructions here:

replace=("5c 1280 800")

Note: I had to replace this line by ("5c 1280 800 32") because a 24 bit depth didn't work for me (why?).

Then add it to run at startup:

rc-update add 915resolution default

Now, you can either reboot or start /etc/init.d/915resolution manually and start your X-Server.

Configuring Special Keys: brightness, volume...

pommed alternatives

pbbuttonsd

The new pbbuttonsd supports the Macbook Pros (MacBooks?) quite nicely, including automatic backlight and keyboard light adjustments; the daemon is ACPI-aware so the auto-adjustments have two different configurations (for battery and AC).

Discussion in Forum

"pbbuttonsd" requires some configuration and doesn't support all the features your MacBook/MacBook Pro has (Remote, automatic keyboard backlight...).

pbbuttonsd for special key functions and power management features, gtkpbbuttons will show your volume, brightness when they are changed

emerge pbbuttonsd gtkpbbuttons

File: /etc/pbbuttonsd.conf
# Configuration file for PBButtonsd >= Version 0.5
# for complete list of options please see pbbuttonsd.conf man-page

# [SYSTEM]
userallowed           = "your_user"        ; user who is allowed to use IPC
autorescan            = yes             ; automatic rescan of event devices
CmdTimeout            = 8

# [MODULE MIXER]
SoundSystem           = ALSA            ; none, auto, OSS or ALSA
#Volume                = 50             ; initial volume level
#Speakers_muted        = no             ; mute after startup?
VolumeUpKey           = 115             ; showkey -k from console
VolumeDownKey         = 114             ; not from xev
MuteKey               = 113             ;
#ALSA_Card             = "default"      ; settings for ALSA
ALSA_Elements         = "Front"         ; Front Speaker (from amixer)
#MixerInitDelay        = no

# [MODULE CDROM]
dev_CDROM             = "/dev/cdrom"
EjectCDKey            = 161
EjectCDKeyDelay       = 1


Start the daemon:

/etc/init.d/pbbuttonsd start

as user:

gtkpbbuttons -t MacOSX

macbook-backlight

There's a tool to control the backlight intensity. You can find it here. This does not work with the Pro version (verified? Works just fine on a pro here, and has been for some time). I have done a setup of acpid switching to a "battery" runlevel where i have a init-script reducing the brightness of my display automatically when running on battery (look here). Switching off backlight via DPMS suspend seems to work.

Do the following to use it (I use gcc as my compiler, but you may need something different): First change directories to where you saved the file, then:

gcc macbook-backlight.c -o/usr/bin/macbook-backlight -lpci #which will compile the executable
chmod u+s /usr/bin/macbook-backlight

Then you can set your backlight intensity by running:

macbook-backlight n #"n" being some number from 31-148

Or you can change your intensity incrementally by running:

macbook-backlight +n #(or -n)

I used xmodmap (to name the Fkeys for use) and xbindkeys to have f1 lower by 10, and f2 to raise by 10. Both are in portage.

Note: Core 2 Duo users have to change

#define VIDEO_CARD_ADDRESS    0x90380000 /* taken from lspci, 512K region */

to

#define VIDEO_CARD_ADDRESS    0x50380000 /* taken from lspci, 512K region */


Note: On my Core 2 Duo I get an "unexpected maximum brightness value" error whenever I try macbook-backlight -n or +n. Keeping it as 90380000 allows me to change the brightness -- Nick Dec 30 2006

Note: On my Core 2 Duo MackBook (not Pro) I get same error: as lspci said, I put ADDRESS 0x30300000, so it works -- User:syschris Jan 09 2007

Note: On my Core 2 Duo MacBook (not Pro) I'm on same case. Even lcpci said ADDRESS is 50380000. On New macbook-backlight.c. 00061254 is default REGISTER_OFFSET. you don't need to change this value. it works just fine.

Note: The backlight of the newest Core 2 Duo MacBooks (November 2007) can be controlled by the tool xbacklight availible in portage. That works just great for me. MSchnaubelt


There are also macbook pro tools that work with the MBP at this address: link title. There is also a tool there called keyboard brigthness (sic) that enables you to change the keyboard light level. The applesmc module must be loaded for this to work. Incidentally, be aware that if applesmc fails to load with led_classdev_register errors, you have to compile led and led class support into your kernel. The blscreen config file on this page does not include that setting.

These tools are unneeded if you have pbbuttonsd or pommed installed.

Touchpad

Setup Manually

Check your /etc/modules.autoload.d/kernel-2.6 and make sure that you have the following modules loaded (in that order!):

uhci_hcd
evdev
appletouch
usbhid
mousedev

And this goes into your xorg.conf:

Section "InputDevice"
       Identifier      "Synaptics Touchpad"
       Driver          "synaptics"
       Option          "CorePointer"
       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"
EndSection

This config gives you not only "tap-to-click" but also "two-finger-tap for middle click" and "three-finger-tap for right click"! If you want to switch it so that two-finger-tap is right click and three-finger-tap is middle click, just use

  Option "TapButton2" "3"
  Option "TapButton3" "2"

Vertical/horizontal scrolling is achieved by moving the finger at the right/bottom edge of the pad. You can also activate a "Mac-style" two-finger-scrolling behaviour with

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

Note: Make sure you have the module order correct. Didn't compile mousedev as a module though. I also had to disable the Mouse0 Corepointer in ServerLayout to get it to work. --Smeedy 21:26, 18 May 2007 (UTC)

gsynaptics and kernel modules

Make a file in /etc/modprobe.d.

Unnecessary, with kernels after 2.6.21 and gsynaptics-0.9.10

nano /etc/modprobe.d/touchpad

and add the line:

install usbhid /sbin/modprobe appletouch; /sbin/modprobe --ignore-install usbhid $CMDLINE_OPTS

Restart X server.

Hardware sensors

maybe the paragraph can be moved out of the unsolved section, with the solutions given ?

Partitioning Questions

Who has played around with partitioning? What options are there?

If only OSX and Linux can read GPT partitions, http://modular.math.washington.edu/macbook/ seems to suggest that a) parted can safely create GPT partitions, and b) one can safely create more than four such partitions. However it conversely suggests that there is no way to resize an existing OSX install (without Boot Camp? I thought Boot Camp could...).

Can you totally remove OSX and use GPT partitions with parted (my guess is yes if you use rEFIt)? Can you totally remove OSX and use MBR partitions with fdisk (my guess is no, unless you can install lilo as the only boot loader)?

Bssteph 06:50, 30 May 2006 (UTC)

Actually, I guess (and this is from memory at the moment) since you need to "bless" rEFIt, you probably a) need that small first partition used for the bootloader and b) need OSX to do the blessing. It'd be great if someone figured this out though. Or can you bless in non-OSX?
Bssteph 17:10, 31 May 2006 (UTC)

Also, you might want to keep a small but working OS X installation to be able to install possible future firmware upgrades from Apple.

You may want to take a look at http://refit.sourceforge.net/myths to learn what works and what doesn't.

 ?????

How big is the FAT32 EFI partition? Has anyone tried using it as /boot? This would enable LUKS encryption even with windows installed, or LUKS and swap. I realize there could be security concerns from having the kernel on a partition that doesn't support privileges, but if you set it as noauto in fstab and don't put users as an option, the only way for anyone to get at it would be with a livecd - Which they could do before anyway, making you safer because you now have an encrypted / partition.

EDIT: I read Apple's EFI docs, and answered some of my own questions. It's a 200MB partition, and it is technically not FAT32 (It's an "EFI filesystem" that currently happens to be pretty much the same as FAT32). As it starts out empty, might it be wise to back it up while it would take up very little compressed space, just in case formatting it with "true" FAT32 would break it? (the apple docs warn against such formatting, and provide a special tool to create such a partition.)

I played A lot with my macbook this weekend and came to the conclusion I added to the wiki on the section "Alternate Partitionning Method 2". You can correct any error you see.

Power Management Questions

What's about Suspend to Ram? When i wake up my macbook, the screen stays black. Could anyone write how to get it working?

Blscreen Maybe we can remove Suspend to Ram from the "unresolved" section?

xkbset

I have been noticing I have to rerun 'xkbset m' from time to time, because the effect of it making X to recognise keyboard keys as mouse keys does not last indefinitely. It usually stops working after a couple of hours. Has anyone noticed it as well? Mr.Rocks 01:22, 17 August 2006 (UTC)

Found the reason. xkbset has a default expiry time of 120 s. To set it to indefinite (for mouse keys) one has to run first 'xkbset exp m'. Mr.Rocks 05:18, 17 August 2006 (UTC)

xmodmap German layout

'keycode 46 = l L lstroke Lstroke at at' is usefull to have the @ where it is printed on the keyboard (L-Key).

Hardware Fixes

Power Management

Frequency Scaling

Works perfectly using speedstep_centrino, which is already built-in in the above provided kernel configuration.

The default scaling governor used in the above kernel is performance which will use the maximum avialable frequency. You might want to use or compile other governors in the kernel config.

Powersaving

Underclock ATI graphic card

If you don't need the full graphic power you can underclock the card:

# /opt/ati/bin/aticonfig --list-powerstates
core/mem      [flags]
-----------------
1: 128/135 MHz  [low voltage]
* 2: 311/297 MHz  [performance mode, default state]
3: 311/297 MHz
# /opt/ati/bin/aticonfig --set-powerstate=1

When I whant to read my powerstates with:

# /opt/ati/bin/aticonfig --list-powerstates

I get:

Error: POWERplay is not supported on your hardware.

I used refit and BootCamp to create partitions (kernel 2.6.21-gentoo-r2, mactel-patches and ati-driver 8.37-6.r1


hi! I've just changed and re-embedded the powersaving stuff. The one with the failure got a second generation Macbook Pro (C2D), instead of a Core Duo (first, and to make it sure, nvidia based mbps are the third generation). There has been made available a workaround that works flawlessly here. Even on a 32bit environment.

Fore more, see here: http://ati.cchtml.com/show_bug.cgi?id=608#c9

And imho, this is quite important because of the gaining of capacity and the less noise..

xentric 14:45, 17 September 2007 (UTC)

Dimming the backlight and throttling the CPUs

A nice ACPI script can be found over at this page: http://www.odi.ch/prog/macbookpro/#17

  1. create files as shown on the page
  2. copy the script to /usr/local/bin/acpi-power
  3. chmod +x /usr/local/bin/acpi-power
  4. check that /usr/bin/backlight exists or change the location in the acpi-power script


Automatically dim the backlight when the power cord is unplugged

Please refer to http://www.gentoo.org/doc/en/power-management-guide.xml

Note: Pbbuttonsd (the 0.8.0 release candidates, here are discussion and links to ebuilds) and the Gnome Power Manager since version 2.18 can manage these automatic adjustments too (acpid is used if running but pbbuttonsd falls back to /proc/acpi entries otherwise).

1) Install ACPID (you must have ACPI enabled in your kernel)

# emerge sys-power/acpid
# /etc/init.d/acpid start
# rc-update add acpid default

2) Create a battery runlevel

# cd /etc/runlevels
# cp -a default battery

3) Get on_ac_power

# emerge powermgmt-base

4) Create the script to change runlevels when an ACPI power/battery event is recieved Save this as /etc/acpi/actions/pmg_switch_runlevel.sh

#!/bin/bash

# BEGIN configuration
RUNLEVEL_AC="default"
RUNLEVEL_BATTERY="battery"
# END configuration


if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
then
    logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
    exit 1
fi

if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
then
    logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
    exit 1
fi

if on_ac_power
then
    if  [["$(</var/lib/init.d/softlevel)" != "${RUNLEVEL AC}"]] 
    then
        logger "Switching to ${RUNLEVEL_AC} runlevel"
         /sbin/rc ${RUNLEVEL_AC}
    fi
elif  [["$(</var/lib/init.d/softlevel)" != "${RUNLEVEL BATTERY}"]] 
then
    logger "Switching to ${RUNLEVEL_BATTERY} runlevel"
    /sbin/rc ${RUNLEVEL_BATTERY}
fi

Don't forget to give it the executable permission

# chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh

5) Run the script when ac_power or battery ACPI events are recieved Save as /etc/acpi/events/pmg_ac_adapter:

event=ac_adapter.*
action=/etc/acpi/actions/pmg_switch_runlevel.sh %e

Save as /etc/acpi/events/pmg_battery:

event=battery.*
action=/etc/acpi/actions/pmg_switch_runlevel.sh %e

You will need to restart acpid

# /etc/init.d/acpid restart

6) Create an initscript to change the brightness /etc/init.d/lcd-brightness

#!/sbin/runscript

set_brightness() {
	if on_ac_power
	then
		LEVEL=${BRIGHTNESS_AC:-148}
	else
		LEVEL=${BRIGHTNESS_BATTERY:-32}
	fi
	
	ebegin "Setting LCD brightness"
	/usr/bin/macbook-backlight ${LEVEL}
	eend $?
}

start() {
	set_brightness
}

stop() {
	set_brightness
}

Don't forget to give it the executable permission

# chmod 755 /etc/init.d/lcd-brightness

/etc/conf.d/lcd-brightness

BRIGHTNESS_AC=148
BRIGHTNESS_battery=31

Set the initscript to run when entering or leaving the battery runlevel

# rc-update add lcd-brightness battery


It makes the most sense to combine this setting with the reading from the environment light sensors under: cat /sys/devices/platform/applesmc/light

However a cool party feature is also: echo "ide-disk" > /sys/devices/platform/applesmc/leds:smc:kbd_backlight/trigger Back to normal with: echo "none" > /sys/devices/platform/applesmc/leds:smc:kbd_backlight/trigger

Luxury Items

Beryl

AIGLX and Beryl both work (here's proof) if you have direct rendering working. Just follow the AIGLX and Beryl tutorials.


Note! For me Aiglx doesn't work. I've got MacBook with i915 chip. Beryl crashes after few seconds. But Xgl works out of the box with drivers from x11-drm so better use them :) --szamot 22:36, 4 December 2006 (UTC)

I just got it working! Just reemerge xorg with aiglx and beryl like the wiki says. I didn't do anything special. Its amazing!! (i'm using xfce, but probably works with kde/gnome)

-- I have a Macbook Pro and have installed the ATI drivers. When turning the Composite option on in Extensions Xorg says that DRI is not supported on screen 0, and when turning Composite off, Beryl complains that it didn't find a Composite capable display. I've installed XGl and that works kind of. It starts Xorg on display 0, then starts X on display 1. This disables the use of any 3D applications besides Beryl. I am assuming that it is possible to compile glx apps to use xgl? not sure but it's clear that AIGLX is superior to Xgl. This should really be updated with a section on getting it to work on the Macbook Pro, if possible. For those interested in my solution, just follow the Gentoo xeffects howto and the ATI drivers howto.

To start it with xfce4 i had to create the file $HOME/.config/xfce4/xinitrc and add

rm $HOME/.beryl-managerc beryl-manager 2>&1 > $HOME/.beryl-log & sleep 4 exec sh /etc/xdg/xfce4/xinitrc

Beryl started to not load whenever i recompiled the kernel or exited X and then restart it. If that happens, delete ~/.beryl-managerc and see if that fixes things.


If you want to use beryl-manager alone (without KDE, Gnome or xfce4), you'll lack some feature. Fortunately there are other ways to get them :-) Here's brief list of things to set to make life easier on a MacBook: First thing first, the main configs: make.conf:

  CFLAGS="-O2 -march=prescott -fomit-frame-pointer -pipe"
  CHOST="i686-pc-linux-gnu"
  CXXFLAGS="${CFLAGS}"
  MAKEOPTS="-j3"
  VIDEO_CARDS="i810 vesa v4l"
  INPUT_DEVICES="keyboard mouse synaptics evdev"
  
  USE="X aiglx dri opengl bluetooth ieee1394 v4l cdr dvdr alsa jpeg png mng sdl usb 3dnow mmx sse sse2 wifi xinerama xv bzip2 zlib"

Compile kernel (emerge gentoo-sources-2.6.18-r4, with mactel patches as "Cheating portage" says, get blscreen's config, and compile the following modules: intel-agp, i915) /etc/portage/package.keywords - keep it as simple as can be (note, no X related keywords!):

  #hardware
  sys-apps/915resolution ~x86
  #Beryl Core
  x11-wm/beryl -* ~x86
  x11-wm/beryl-core -* ~x86
  x11-plugins/beryl-plugins -* ~x86
  x11-plugins/beryl-dbus -* ~x86
  x11-plugins/beryl-vidcap -* ~x86
  x11-misc/beryl-manager -* ~x86
  x11-misc/beryl-settings -* ~x86
  x11-apps/xlsclients -* ~x86
  #Window Decorators
  x11-wm/emerald -* ~x86
  x11-misc/emerald-themes -* ~x86
  x11-themes/emerald-themes -* ~x86

and the xorg.conf (extract, compare each section to your's):

  Section "Module"
   Load    "extmod"
   Load    "i2c"
   Load    "bitmap"
   Load    "ddc"
   Load    "vbe"
   Load    "dri"
   Load    "glx"
   Load    "freetype"
   Load    "type1"
   Load    "synaptics"
  EndSection
  Section "Device"
   Identifier      "Intel Corporation Mobile Integrated Graphics Controller"
   Driver          "i810"
   BusID           "PCI:0:2:0"
   Option          "DRI"     "true"
   Option          "SWCursor"      "false"
   Option          "GARTSize"      "64"
   VideoRam        65535
  EndSection
  Section "Screen"
   DefaultDepth    24
   SubSection "Display"
    Depth           24
    Modes           "1280x800"
   EndSubSection
   Option  "Accel"         "true"
   Option  "XAANoOffscreenPixmaps" "true"
  EndSection
  Section "ServerFlags"
   Option          "AIGLX" "true"
  EndSection

Emerge modular X 7.1 (don't modify /etc/portage/packages.*!!!, even if the howto says so, and don't use x11-drm! Kernel's DRI driver works out of box on a white MacBook!). Then do

  emerge beryl emerald alsa-tools eject xmodmap xbindkeys feh

and get the macbook-backlight tool and 915resolution. We are almost done, we have to create some config files. First get the mouse buttons and normal Fx behaviour: /etc/conf.d/local.start:

  echo -n 0x02 >/sys/module/usbhid/parameters/pb_fnmode
  
  echo 1 >/proc/sys/dev/mac_hid/mouse_button_emulation
  echo 126 >/proc/sys/dev/mac_hid/mouse_button2_keycode
  echo 96 >/proc/sys/dev/mac_hid/mouse_button3_keycode

this will let you have middle and right mouse buttons on right Apple key and the key next to it. Specify some more keys: $HOME/.xmodmap:

  keycode 153 = Right
  keycode 144 = Left
  keycode 176 = 0
  keycode 174 = 9
  keycode 162 = space
  keycode 158 = f
  
  keycode 115 = Super_L
  keycode 95 = Delete
  keycode 96 = Insert
  keycode 204 = F13

This will let you have left Apple key act as Windows key, you'll be able to use remote in mplayer. F11 will become Delete key and F12 Insert. It also specifies the Eject key as F13 ;-). Now, let's get Apple specific keys to work! Create $HOME/.xbindkeys:

  "macbook-backlight -10"
  Mod4 + F1
  
  "macbook-backlight +10"
  Mod4 + F2
  
  "amixer sset Front 0"
  Mod4 + F3
  
  "amixer sset Front 9-"
  Mod4 + F4
  
  "amixer sset Front 9+"
  Mod4 + F5
  
  "eject"
  F13

and that's it! You can use the brightness, volume keys with the left Apple key + Fx as expected (NOTE: not with the Fn key, but with left Apple), and Eject key will also eject CDs! :-) Finally, let's put things together in $HOME/.xinitrc:

  beryl-manager &                           #run manager, because we're useing it alone
  beryl &                                   #start beryl
  xmodmap $HOME/.xmodmap                    #get the keys
  xbindkeys                                 #and bind them
  feh --bg-scale ~/Images/background.jpg &  #let's have a nice background
  emerald                                   #and finally start decorator in foreground.

Note that exiting the decorator will also exit your session. Cheers! Hope good for someone, it took me days to figure all of it out! Turdus 19-12-2006


AIGLX/Beryl Errors

I have not been able to get AIGLX working with the 2.6.19 kernel. (I checked it with the 2.6.19-r2 kernel. If someone wants to test a latter revision tell me if it works) It always crashes with "fatal IO error 104 (Connection reset by peer)"

I get the error "libGL warning: 3D driver claims to not support visual 0x5b" when i run google earth If anyone knows why this error occurs and/or how to fix it please post!

WiFi

From my experience, I needed wireless-tools >= 29pre10 and possibly wpa_supplicant > 0.4.9 to get the wireless working. Without this, NetworkManager would make an unsupported call when trying to connect to a wireless network. This should probably be mentioned in the WIFI section.

I tried using the latest stable (in the portage tree) ndiswrapper w/ the newer atheros card to no avail (kernel panic on module load). Switching to the unstable version worked (1.38)

--Bad code 07:18, 16 March 2007 (UTC)

For those with problems using the newer ndiswrapper and wpa_supplicant, try using the WEXT driver instead of ndiswrapper. As explained in wpa_supplicant howto here, you can set the driver wpa_supplicant uses for your card by specifying it the correct command line argument in /etc/conf.d/net:

File: /etc/conf.d/net snip
modules=( "wpa_supplicant" )
wpa_supplicant_wlan0="-Dwext"
#... config eth0 below...

--Bad code 03:37, 21 March 2007 (UTC)

Sound

Alsa-drivers: I tried to install alsa-driver 0.12 and 0.13 to get the normal audio behaviour as Blscreen explained in the howto. I also had to disable alsa in the kernel to get the alsa-drivers compiled. But i had no success with the speakers. I am using Macbook Pro with kernel 2.6.18 and all patches except the sigmatel patch. Now, i get sound only through the line-out plug and the speakers are still not working. -Sammy

Microphone: I got the internal mic up and running with the kernel-patch variant (2.6.18-gentoo-r3). But now I only have sound through headphones, no internal speaker! The microphone is louder under OSX than under linux.

Edit: vanilla-2.6.19-rc6-mactel Mic and internal speaker work! But the microphone is still very quiet.


On Macbooks shipped late 2007: snd-hda-intel doesn't seem to recognize the codec quite correctly; on my Macbook, it would only issue

hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...

and then not work. Using a very recent kernel (2.6.24_rc*) which I think includes the latest alsa (1.0.15) and adding the model=mbp3 (that's meant for MacBook Pro, actually) helped for me. The full and working /etc/modprobe.d/alsa:

# ALSA portion
alias char-major-116 snd
alias snd-card-0 snd-hda-intel

# module options should go here
options snd-hda-intel model=mbp3

# OSS/Free portion
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0

# card #1
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss

Afterwards run update-modules.

Filesystems

I get the following error on reboot:

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,3)

I've tried tweaking about the lilo.conf and fstab files.... It's not workin', and I'm sad.--Mstahl 05:57, 4 November 2006 (UTC)

i get the same error but only if i use a selfmade kernel. if i usa a genkernel it works?!?

Camel If you forget to enable kernel support for your filesystem, you're boned. I tried to compile a kernel without reiserfs support and boot off of a reiserfs partition, and got this exact error message. Simple fix: boot off livecd, chroot, recompile with reiserfs support enabled.

Didn't work for me. My / partition is ext3 and ext3 support is compiled into the kernel. Something amiss with my /etc/fstab? Something? Anything? I'm lost --Mstahl 06:12, 5 December 2006 (UTC)

Having the same problem, see this thread: http://forums.gentoo.org/viewtopic-p-3758220.html#3758220 (vanilla 2.6.19 + mactel patches)

Adding rootdelay=5 to the kernel options in grub seems to solve the problem for me. It's clumsy, but works. --Andrew


running kernel 2.6.20 for 3 days and no kernel panic at boot! (without rootdelay!)

it's been discussed on the mactel-linux-users mailing list that 2.6.21 fixes the intermittent "unknown root fs" problems

xmodmap and kde

For a long period of time I had no problems with running xmodmap ~/.XModmap with a script in ~/.kde/Autostart. A few days ago, however, something in my setup must have changed and the script ended up being processed after all windows from previous sessions were loaded (quite a few) and so it took me a day to figure out that it worked fine calling xmodmap with new windows but not existing ones. I simply edited /usr/kde/$VER/share/config/kdm/Xstartup to include a line calling exec xmodmap /etc/X11/Xmodmap. Posted this just in case I'm not the only that encountered this. grahl

xmodmap: up/down

Instead of

keycode 98 = 0xff52 NoSymbol 0xff55
keycode 104 = 0xff54 NoSymbol 0xff56

i suggest

keycode 98 = 0xff52 0xff55 0xff55
keycode 104 = 0xff54 0xff56 0xff56

Scrolling in e.g. rxvt needs Shift+PageUp/PageDown. With my change, Shift Cursor Up/Down would do the job, thus removing the need to press three keys. -- 80.139.34.60 20:39, 20 November 2006 (UTC)


Battery life

I'm not that happy with the battery life under linux. It's only about 2 hours! Backlight is most of the time set to 150, keyboard backlight is always off. Using the conservativ govenor for the CPU and KLaptop. WLan and bluetooth are off. Anyone has the same experience?

This is caused by the ati graphics card, which always runs at high speed if you don't throttle it manually. See Powersaving [updated on Sept 17, 2007] for more details. You'll gain about 1 up to 1.5hrs (2.5 - 3 in all).

lspci lsusb output and table with status

Is is possible to update the article with output of lspci and lsusb and add a table with description of what is works and what is not? :.Dmitri

CHOST

With the Core 2 Duo Macbooks, a question comes to mind regarding the choice of LiveCD. The article states that either LiveCD can be used, but the choice determines what type of system you want (32- or 64-bit). Obviously this is the case with only packages from the LiveCD, but if either LiveCD will run successfully, it seems better to say simply that either one will run, or just to pick one to recommend. Then later, when setting CHOST, this choice can be made. I suppose the selection of stage3 tarball would affect the resulting system, and if one was installing with a package CD instead of a minimal CD, this would in turn matter, but isn't an emerge -e world usually a good idea after fixing make.conf the way you want anyway?

I'm mostly saying that this should probably be clarified, and the decision should probably be explained and made at another step in the installation.

Additionally, I'd like to add that I run an AMD64 machine and it runs binary ati-drivers as happily as binary ati-drivers can run (which isn't very happily, but that's another argument altogether).

--Adlaiff6 22:54, 18 January 2007 (UTC)

CFLAGS

It has been confirmed by hongjiu.lu@intel.com that prescott is the correct microarchitecture to use with this CPU.

Underclocking ATI

When I try underclocking the ATI card, I get an error that PowerPLAY is not supported by the hardware. rovtool reports mem speed @ 0 MHz. Any ideas?

oh hell, this page is a mess ;) Yes, i've just added a new section with a link to a workaround. Simply take a look at http://ati.cchtml.com/show_bug.cgi?id=608#c9, this will help you and saves ~7-8W per hour.

Xentric 15:01, 17 September 2007 (UTC)

Synaptics Touchpad

the udev rule:

SUBSYSTEM=="input",KERNEL=="event*",SYSFS{name}=="appletouch",SYMLINK+="input/appletouchpad"

doesnt work for kernel 2.6.20 and I dont know why(udev104).

I tried appletouch as modul and build-in, can someone help me?

I've had trouble getting the touchpad to work at all with the synaptic driver. Doing a cat of /proc/bus/input/devices doesn't list anything with Synaptic in it, only two references to the "Apple Computer Apple Internal Keyboard / Trackpad" one of which has kbd as its handler and the other has mouse0. The other two devices seem to be generic usb-hid events that correspond to the same keyboard and touchpad. To answer the above question, if you're having the same issue I am, the SYSFS{name}=="appletouch" isn't matching any devices, because the name field is showing up as "Apple Computer Apple Internal Keyboard / Trackpad". I've got the latest version of the synaptic driver, the input section of my xorg.conf is identical to the example, except that I've tried every combination I can think of for the Option "Device" line: /dev/psaux, /dev/input/mice, /dev/input/event0 ... /dev/input/event5, /dev/input/mouse0, /dev/input/mouse1. All of which come back with the same error after xorg fails to start:

Synaptics Touchpad no synaptics event device found

The following site describes it the best, but the posted solution was to hack in some kernel code: http://www.mail-archive.com/mactel-linux-users@lists.sourceforge.net/msg00310.html --Bad code 09:14, 17 March 2007 (UTC)

Should this page recommend the minimal CD instead of the LiveCD?

This page says, "The best choice for installing Gentoo is the Live CD."

I used the LiveCD, and it worked, but other than the initial command-line boot environment I don't think I used anything on the CD. For the most part, the packages on a 2006.1 LiveCD are too old to work well on a Core 2 Duo MacBook. The graphical install environment doesn't work, and the automatic installer also doesn't work.

So I'm wondering if it would be better to recommend the minimal installation CD, which would save 80% of the download.

Has anyone had experience installing from a minimal Gentoo CD onto a MacBook?

TiccTech 02:13, 7 March 2007 (UTC)

I've been using the minimal Gentoo CD with no problems.

Joe 10:01, 18 June 2007 (PST)

Actually, the only thing required to install Gentoo on a MacBook is a Linux prompt. I successfully completed a Gentoo installation using a Kubuntu LiveCD, which is excellent because Kubuntu supports the MacBook's wireless hardware out of the box.

Wireless Mighty Mouse

  • I'm thinking about buying a Macbook pro with a Wireless Mighty Mouse. But I'm love Linux and use it all the time. So does this mouse work with Linux and it's scroll ball work? --T0ny 19:33, 15 March 2007 (UTC)
I have the mighty mouse. It works extremely well with hidd, but I cannot get the scroll ball to work.
Never mind, the bluetooth module was in hid mode, so I edited /etc/conf.d/bluetooth 's HID2HCI line and is works.

DVI and TV Out

Has anyone succeeded in getting the DVI-out adapter working under Linux? VGA works fine for me but DVI does not deliver a signal to my external monitor, even if plugged in before boot. OS X works fine, so the problem is not with the adapter.

Ditto for the TV out. My VGA adaptor works fine (I guess one of us should post a config some time) but I can't get a good signal with the TV out. You can see that it's trying -- dragging windows around produces different crap noise -- but that's it.
Bssteph 09:53, 14 April 2007 (UTC)
Exactly the same problem here with the TV out... did you find a way to solve it ? (Macbook second gen. and apple adapter)
Have a DVI Samsung in clone mode with a different resolution. Haven't made any special config to the device section. EDID info is present in Xorg log. --Smeedy 21:56, 18 May 2007 (UTC)
Does it make a difference whether you have an ATI or an Intel graphics card? I haven't been able to get so much as a flicker on my Dell 2407WFP using DVI out (and I'm using an Intel card). It would be nice if someone would post a working xorg.conf file with dual screens.
I have an intel card, and vga out works like a charm using xrandr to set the output. tv out doesn't work at all, I haven't tried dvi yet (I don't have a mini DVI-> DVI convertor). I'm guessing the normal detection mechanism, which detects if a tv is attached to the laptop doesn't work on a macbook. Maybe a hack to the driver could help ;)

Split and disambiguation

This page is too long and as such is hard to maintain. However, it contains a lot of useful information. It seems to me that the Mactels (Mac Book, MacBook Pro, Mac Pro, Mac Mini, etc.) share a lot of hardware (and all obviously run Mac OS X) and hence require very similar instructions regarding the installation.

It would probably be useful to have a common trunk for all this hardware:

and maybe even these could share some ressources. Synss 07:03, 1 June 2007 (UTC)

The problem with this page is that it's about a subject which very few people are knowledgable about, namely, how to install Gentoo on every MacBook in existance. Most people are knowledgable about a much simpler subject, namely, how to install Gentoo on the particular model of MacBook that they own.
I wouldn't even bother with linking together the "similar instructions" and instead just create a seperate page for each type and submodel of MacBook. For example, I have a "MacBook3,1" (which is the preferred name, not the rosawhatever everyone keeps calling it, as if you look at "about this Mac" in MacOS, it calls it "MacBook3,1") and the MacBook3,1 has different hardware to the extent that a lot of the text in this wiki doesn't apply to it at all. That text is a waste of time to me as a reader, and it's a lot of needless complexity to me as a potential editor. This article is a mess, and I'd say that's because it's really a dozen articles put together into one, creating one far to complex article full of conditionals and constantly changing information, which is just too much for the average person to look at, let alone make constructive modifications to.
There's also the assumption that if I don't see an exception for "MacBook3,1" that whatever other text exists applies, but this isn't necessarily true. I think an entierly seperate article would be better, as then someone can just copy the information from an article on the "MacBook2,1" if it's the same, and if it isn't the same, then the information can remain missing until someone learns the correct information.
This article is massive, difficult to read, and missing important information, like just how does one install Gentoo on a MacBook3,1 considering that both the ethernet and wireless don't work. I eventually figured out that the easiest method was not the Live CD but instead to put the necessary files on a USB flash drive, and I'd love to share that information, but this article is just too big. It's so big I don't want to touch it, I seemingly can't touch it as the "edit" links don't bring up the correct sections to edit, and even if I could touch it, I'm not sure it'd be worth my time as I myself gave up on this article after the first day and simply went about figuring out how to install Gentoo without it because this article was too large, too unorganized, and it contained too much misinformation.
The easiest way to fix everything wrong with this article is to create a seperate article for every model and submodel of Mac hardware, and simply rely on the fact that the narrow scope of each article will make it so that there are many more experts on each article's topic to make up for the fact that a lot of the information will be duplicated. Besides, it isn't as if this is information that requires constant maintanence anyway. It does in it's current form, but that's only because people need to constantly add exceptions for each new type of Mac. With seperate pages, however, once someone's written instructions for a "MacBook2,1" there's no need at all to modify that page just because the "MacBook3,1" was released. The only real change I can imagine would be deleting information as the kernel comes to support more and more of the hardware by default, requiring fewer workarounds.
So, yeah, my vote is seperate articles, and I personally see no reason at all to wait on a vote tally because as a user of these instructions, I claim they're borderline useless in their current form, so I can't imagine how one could go wrong seperating them into individual pages as the result certainly couldn't be any worse. -- 24.209.110.27 23:58, 7 January 2008 (UTC)

SysReq

I'm wondering whether it's possible to use SysReq on the macbook keyboard... Since there aren't any sysrq nor printscr keys I wasn't able to use it yet.

Last modified: Fri, 29 Aug 2008 08:28:00 +1000 Hits: 7,405

Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.