Jump to content

Setting Up Ubuntu on a MacBook (complete guide)


4 posts in this topic

Recommended Posts

Ok here's a little info:


Why post this?

Because it took me a fair deal of tinkering to get the system running right, then I had to reinstall *everything* because OSX didn't want to shrink further, and so I recorded all my steps as best as I could - This should work with a clean install


This is not detailed enough!!?!?!?!!!!1111

It should give you a fairly good idea of what I mean, commands and stuff are there.

Basically I wrote down as much extra text as I thought I would need to remember some of the theory behind the fixes/changes, but that's it.



1) Installed Ubuntu, Macbook Keyboard, dk layout


2) Grub changes

edit /boot/grub/menu.lst as root

edited defoptions in grub to contain: vga=0x318 lpj=8645184 too

edited the two existing kernels too


The idea here is that the edits at the kernel lines apply to the currently used kernels. Defoptions is a string used by

ubunto to suffix a few default kernel options each and every time a new kernel is installed, so you have to edit this line

to make these things automatically used even when the system goes through a kernel upgrade.

Also, lpj can have different values. I used this one since I have a 2.13gHz MacBook. Usually a google for linux, lpj and macbook

will yield good results on what you must use.


3) Did a full update of the base system (including kernel)


4) Getting Suspend / Hibernation

apt-get install uswsusp (for s2ram/s2disk)


then read edit sleep scripts ! (AT the bottom)


! In step 8 we'll set it up in gnome to run when the lid is closed, step 5

is REQUIRED for the suspend functions to work correctly!


5) Video Drivers & Macbook-backlight

sudo apt-get install xserver-xorg-video-intel

change driver from "i810" to "intel"

added a few extra resolutions, checked that 1280x800 was default


wget http://ubuntu.desrt.ca/macbook-backlight_0.0-1_i386.deb

sudo dpkg -i macbook-backlight_0.0-1_i386.deb

sudo chmod u+s /usr/bin/macbook-backlight


Info: http://ubuntuforums.org/showthread.php?t=396371


You may experience a loss of backlight after suspending

if you haven't changed the video driver!


6) Install madwifi for wireless

! Again, this is for RECENT macbooks, older macbooks use an intel chipset which I'm told works out of the box. Lucky you :D

-obtain madwifi sources @ MadWifi Source Forge Page

sudo apt-get install build-essential linux-source

cd /usr/src/

tar -xvjf linux-source-2.6.20.tar.bz2 (substitute version numbers for your kernel!)

cd /path/to/madwifi-hal-[VERSION]


sudo make install

(select yes to remove prior madwifi modules when questioned!)

Yes, unfortunately you will HAVE to do this whenever you upgrade your kernel - but strictly speaking, if it works

don't fix it ! (meaning unnecessary kernel upgrades are really not the best idea)


7) Fixing the keyboard


!Reverse the fnmode (so that F1-F12 keys are default instead of fn keys)

Create a file in /etc/modprobe.d/ (I'll call mine applekeyboard)



Depending on the kernel, pick one of the two lines:

"options hid pb_fnmode=2" (kernels >= 2.6.20)

"options usbhid pb_fnmode=2" (kernels < 2.6.20 older kernels)


For ubuntu feisty, that's the "options hid pb_fnmode=2"

To apply this behaviour instantly (won't be retained over reboots):

"rmmod usbhid && rmmod hid && modprobe hid pb_fnmode=2 && modprobe usbhid" as root!


!Change the Apple-key into the alt-gr key

sudo sed -i~ '/xkb_symbols "ralt_switch" {/a\ include "level3(rwin_switch)"' /etc/X11/xkb/symbols/level3

-MUST restart X for the change to take effect


!Change the key next to the right Apple-key to del

Create an .Xmodmap file and enter:


keycode 108 = Delete



!Set up brightness keys (requires that step 6 is completed)

sudo apt-get install xbindkeys-config

xbindkeys --defaults > ~/.xbindkeysrc

Run xbindkeys-config and set the keys up, click save, apply exit

Add xbindkeys to the session!


8) Minimize Battery drainage

Here we'll activate laptop tools, we'll automatically dim the display when going cordless, we'll grant the user FULL access to the CPU governors and we'll finally enable suspend on lid close.


!Install Laptop Tools

sudo apt-get install laptop-mode-tools

edit /etc/default/acpi-support , set ENABLE_LAPTOP_MODE to "true"


restart acpi-support for immediate results:

sudo /etc/init.d/acpi-support stop

sudo /etc/init.d/acpi-support stop


Check that it works by ripping out the AC cord and polling /proc/sys/vm/laptop_mode like:

cat /proc/sys/vm/laptop_mode


On AC_mode, it should respond 0, but after a while it will respond with a non-zero number, if it works!


Further tweaking can be done in: /etc/laptop-mode/laptop-mode.conf


!Automatically dim the display when switching from AC to battery

For AC, place a file in /etc/acpi/ac.d/ with the lines:



macbook-backlight 148


148 was the max number I could get, executing macbook-backlight with no arguments will show the

current level (number).


For Battery, place a file in /etc/acpi/battery.d with the lines:



macbook-backlight 88



These files (along with the other files in their directories) will automatically be executed when the

computer switched power states.


!Giving the user full control over the CPU (through governors)

Normally you can't do much else than read the display in the cpu manager, let's reconfigure it:

sudo dpkg-reconfigure gnome-applets


Select yes to suid cpufreq applet. Now you can adjust frequency and governors.

POTENTIALLY a security risk, but if it's just you who uses the system, it's more of a bother to sudo in order to change a governor or frequency, it's got limits so you can't melt down the CPU core anyway.


!Enable suspend on lid close

This is actually what we prepared for in step 5, now we'll enable it!

Click through the menu:

System -> Preferences -> Power Management

The the lid action to "suspend" for both AC and Battery, DONE!


9) Compiz

Compiz introduced a couple of redraw problems which seems to be mostly fixed by issueing:

sudo apt-get install 915resolution


Copy and paste this script into a document:

compiz-fixer-sh --------------------------------------------


#Fix some settings which occasionally {censored}s ubuntu desktop effects up

gconftool-2 --type int --set /apps/compiz/general/screen0/options/hsize 4

gconftool-2 --type int --set /apps/compiz/general/screen0/options/number_of_desktops 1


#Set up rotate keys, doesn't work inside keyboard shortcuts....

gconftool-2 --type string --set /apps/compiz/plugins/rotate/allscreens/options/rotate_to_1_key "<Control>1"

gconftool-2 --type string --set /apps/compiz/plugins/rotate/allscreens/options/rotate_to_2_key "<Control>2"

gconftool-2 --type string --set /apps/compiz/plugins/rotate/allscreens/options/rotate_to_3_key "<Control>3"

gconftool-2 --type string --set /apps/compiz/plugins/rotate/allscreens/options/rotate_to_4_key "<Control>4"


#Set up OSX-like exposé

gconftool-2 --type string --set /apps/compiz/plugins/scale/allscreens/options/initiate_output_key "F9" #4 all windows on all desktops

gconftool-2 --type list --list-type string --set /apps/compiz/plugins/scale/allscreens/options/initiate_edge [TopRight] #sets corner for activation

gconftool-2 --type int --set /apps/compiz/plugins/scale/allscreens/options/initiate_edgebutton 0 # from 1 to 0, no keypress required now



I've retained some of the comments I made during the actual creation of the script. Though I'd want to say, that it changes a few registry entries for compiz which alters it's behaviour.


First off, it fixed the "Desktop Effects" enable disable enable bug. Usually when you do this,

you get one workspace and the cube won't work. That's fixed first.


Secondly, it sets you up so that <Control>+[1-4] will cycle through desktops 1 through 4.


Thirdly, it activates the OSX-like Exposé effect so that pressing F9 will tile windows from ALL desktops whereas

simply running the mouse up to the TopRight corner will tile the windows on the current desktop.


10) Desktop Indexing (BEAGLE)

sudo apt-get install beagle


locate beagle-search*.desktop



cp /usr/share/app-install/desktop/beagle-search.desktop ~/Desktop/


Setup F12 for search, depending on the window manager, choose a step:


! Metacity:

gconftool-2 --type string --set /apps/metacity/global_keybindings/run_command_1 "F12"

gconftool-2 --type string --set /apps/metacity/keybinding_commands/command_1 "beagle-search"



gconftool-2 --type string --set /apps/compiz/general/allscreens/options/command0 "beagle-search"

gconftool-2 --type string --set /apps/compiz/general/allscreens/options/run_command0_key "F12"



11) Fix Video Playback

I don't know the exact reason, but whenever compiz is enabled, drivers optimised to use the Xv playback engine will {censored} up when playing videos. The solution is to switch to an alternative (but less efficient) engine, for all

gstreamer-related modules this can be done like so:



Set "Plugin" to "X Window System (No Xv)".

The system will now use X11, XShm or similar alternatives. Seems to work fine


Edit Sleep Scripts

edit /etc/acpi/hibernate.sh and /etc/acpi/sleep.sh

sleep.sh - delete everything, replace with:
if [ -x /sbin/s2ram ]; then
/sbin/s2ram -f
echo -n $ACPI_SLEEP_MODE >/sys/power/state

hibernate.sh - replace:
if [ -x /sbin/s2disk ]; then
DEVICE="/dev/disk/by-uuid/`awk -F= '{print $3}' </etc/initramfs-tools/conf.d/resume`"
if [ -f /etc/usplash.conf ]; then
. /etc/usplash.conf
/sbin/s2disk -x "$xres" -y "$yres" $DEVICE
/sbin/s2disk $DEVICE
echo -n "disk" >/sys/power/state

if [ -x /sbin/s2disk ]; then
echo -n "disk" >/sys/power/state
Warning: haven't actually tested hibernation.




Now, this may look like a lot of work. But I finished this (while re-googling for fixes and stuff) in about 1 hour and 30 minutes so since this is all laid out, you should be able to do a little faster.

I recognize, that some say macbook-backlight isn't needed anymore, it is for me. Also some may have suspend working out of the box, it doesn't for me and what this really boils down to is that some installations behave different, that's all I'm going to say about it.


I hope someone will find a few solutions from this or that it may make people contemplate dualbooting or ejecting OSX too.

Also, to semi-quote newton: If I have seen further it is by standing on the shoulders of Giants.


So thanks to any sites or any person who has written about Linux on the macbook earlier -whether or not it was applicable to my case, it's really appreciated.


That's all :censored2:

Link to comment
Share on other sites

  • 1 month later...

Thanks for the instructions. Still debating whether to actually install bootcamp (and with it, xp & linux) or just keep on using parallels. We'll have to wait till my 2GB ram kit comes from crucial..

Link to comment
Share on other sites


  • Create New...