Sunday, July 13, 2008

Install Ubuntu Hardy Heron (8.04.1) on Macbook

I was forced to upgrade my MacBook a few days ago. I don't mean upgrading the software, AppleCare replaced the MacBook. So I have 4 times the RAM and double the hard disk space now, and a whole bunch of components that don't work with Ubuntu out of the box.

I have a MacBook4,1 (Apple --> About this Mac --> More Info...; look at the "Model Identifier" entry), and the relevent Ubuntu community document pages are:

How to install Ubuntu on a MacBook
MacBook_Santa_Rosa

There are three parts:
  1. Installation: install Ubuntu.
  2. Hardward configuration: configure devices.
  3. Enable some neat software.

Installation

Software Update.
  1. Update Mac OS X.
    Apple Menu -> Software Update...
  2. Update Firmware if needed. See the following webpage.
    http://support.apple.com/kb/HT1237

Install the rEFIt Boot Menu.
  1. Download from http://refit.sourceforge.net.
  2. Mount the image.
  3. Double-click on the "rEFIt.mpkg" icon.
  4. Reboot to make sure rEFIt is installed.

Resize Hard Drive.

From the output of the mount command, look for the disk mounted on /. In my case it is disk0s2. Change the following command accordingly.
diskutil resizeVolume disk0s2 50G
Reboot.

Install Ubuntu 8.04.1.
  1. Download and burn the Ubuntu CD image from www.ubuntu.com. (I used the 64 bit version because I have the Core 2 Duo Macbook.)
  2. Put it in your computer and reboot.
  3. Select the penguin from the rEFIt menu. (Or hold down C while booting.)
  4. Select "Check CD for defects". It takes a while, but is good to do.
  5. Reboot.
  6. Select the penguin from the rEFIt menu.
  7. Select "Start or install Ubuntu". The Ubuntu desktop will load.
  8. Click the Install icon.
  9. Follow the on-screen instructions. Some notes:
    • Make sure to select the US English -- Macintosh keyboard layout.
    • Choose to manually edit the partition table.
    • Make sure that EFI GPT partition is not mounted.
    • Create some partitions (I created: 10G for /; 10G for /scratch; 2G swap; the rest for /home).
    • Also make sure that your partitions are mounted in the correct spots (/, /home,...).
  10. Reboot.
  11. Select "Start Partitioning Tool" at the rEFIt menu. It might ask you to sync the MBR GPT maps. Select yes.
  12. Reboot.
  13. Select the Penguin at the rEFIt menu.

Hardware Configuration

Wireless (BROADCOM BCM4328)

You need to have a wired internet connect for this.

Install firmware:
apt-get update
aptitude install ndiswrapper-utils-1.9

wget http://ftp.us.dell.com/network/R151517.EXE
mkdir driver
unzip -a R151517.EXE -d driver/
cd driver/DRIVER/
Activate:
ndiswrapper -i bcmwl5.inf
ndiswrapper -l
ndiswrapper -m
modprobe ndiswrapper
Activate on startup:
echo ndiswrapper >> /etc/modules
Sound

Add to /etc/modprobe.d/options:
options snd_hda_intel model=mbp3
Reboot.
Right click volume control icon.
Select the Switches tab.
Enable Speaker.

iSight

Reference: Ubuntu Forum Post.

Grab firmware from OSX partition.
sudo mount -t hfsplus /dev/sdax /mnt
sudo cp /mnt/System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBVideoSupport.kext/Contents/MacOS/* /lib/firmware/$(uname -r)
Add Mactel repositories to /etc/apt/sources.list.
# Mactel PPA
deb http://ppa.launchpad.net/mactel-support/ubuntu hardy main
deb-src http://ppa.launchpad.net/mactel-support/ubuntu hardy main
Installation.
apt-get update
apt-get install isight-firmware-tools
ift-extract -a /lib/firmware/$(uname -r)/AppleUSBVideoSupport
Enable changes:
/etc/init.d/hal restart
Test with cheese:
apt-get install cheese
cheese
Touchpad

Add the following InputDevice section to /etc/X11/sorg.conf.
Section "InputDevice"
Identifier "MacBook Touchpad"
Driver "synaptics"
Option "AccelFactor" "0.015"
Option "BottomEdge" "310"
Option "Device" "/dev/psaux"
Option "FingerHigh" "30"
Option "FingerLow" "20"
Option "HorizScrollDelta" "0"
Option "LeftEdge" "100"
Option "MaxDoubleTapTime" "180"
Option "MaxSpeed" "0.88"
Option "MaxTapMove" "220"
Option "MaxTapTime" "150"
Option "MinSpeed" "0.79"
Option "Protocol" "auto-dev"
Option "RightEdge" "1120"
Option "SendCoreEvents" "true"
Option "SHMConfig" "on"
Option "TapButton2" "3"
Option "TapButton3" "2"
Option "TopEdge" "50"
Option "VertScrollDelta" "25"
Option "VertTwoFingerScroll" "true"
EndSection
Change the InputDevice to "Macbook Touchpad" in the ServerLayout section.

Add syndaemon to the startup programs (System --> Preferences --> Sessions).
syndaemon -i 2 -t -d
Mic

It works, the settings just need to be adjusted: open volume control, unmute Mic and Capture; and make sure that Mic is the Input Source.



Software Configuration

Power Consumption

Install powertop.
apt-get install powertop

Run powertop, wait and implement suggestions.
powertop
I got the following suggestions:
  • Suggestion: turn bluetooth off.
    hciconfig hci0 down ; rmmod hci_usb
  • Suggestion: increase the VM dirty writeback time from 5.00 to 15 seconds.
    echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
  • Suggestion: Disable 'hal' from polling your cdrom.
    hal-disable-polling --device /dev/cdrom
Compiz

Enable:
System --> Preferences --> Appearance --> Visual Effects --> Extra
Install settings manager:
apt-get install compizconfig-settings-manager
Edit settings:
System --> Preferences --> Advanced Desktop Effects Settings

Amarok

apt-get install amarok k3b libk3b2-extracodecs


Note: k3b and libk3b2-extracodecs are needed to enable disc burning
from Amarok

Google Gadgets

Add repositories to /etc/apt/sources.list.
## Google Gadgets
deb http://ppa.launchpad.net/googlegadgets/ubuntu hardy main
deb-src http://ppa.launchpad.net/googlegadgets/ubuntu hardy main
Install:
aptitude install google-gadgets
Add to list of startup programs:
System --> Preferences --> Sessions --> Startup Programs --> Add
Name: Google Gadgets
Command: /usr/bin/ggl-gtk -bg
Comment: Google Gadgets
You can add the Google Gadgets to the Widget layer of Compiz.

LaTeX
aptitude install texlive-full vim-latexsuite subversion vim-gtk xpdf
Sage

Install software for compiling Sage:
aptitude apt-get install gcc-4.2-base make m4 bison flex tar perl binutils libstdc++6-dev g++ openssh-client
Download and Install Sage:
wget http://www.sagemath.org/src/sage-3.0.5.tar
tar cvf sage-3.0.5
cd sage-3.0.5
make