Debian Install Tutorial for MacBook

Here I describe simple tutorial to install Debian on Macbook. (initially written for lenny on 2008-10-28)

(!) Please avoid adding corner cases and detail discussions here. Please refer to http://wiki.debian.org/MacBook . Many problems on etch has been resolved too.

(!) Please update your Mac OS X itself and all system softwares including firmware prior to the installation of GNU/Linux.

(!) Have USB connected keyboard ready. Keyboard on MacBook acts funny under some condition.

(!) It may be good idea to use following voodoo phrase as kernel boot parameters:

install noapic irqpoll acpi=force

{i} Booting while pressing "C" key forces system to boot with CD/DVD first before poking HDD.

?TableOfContents(4)

Partition on MacBook

Apple MacBook is build with [http://en.wikipedia.org/wiki/Extensible_Firmware_Interface Extensible Firmware Interface (EFI)] for booting system and has SATA harddisk as main boot disk which deploy new [http://en.wikipedia.org/wiki/GUID_Partition_Table GUID Partition table (GPT)].

This is different from classic PCs which use PC [http://en.wikipedia.org/wiki/BIOS BIOS] to boot and partition data are stored in [http://en.wikipedia.org/wiki/Master_boot_record MBR].

GPT partition data are arranged not to overstep on classic MBR or classic boot record on each partition.

Whenever you update your GPT partition data on the boot disk with utility program which do not know about the hybrid format, your classic MBR record is zapped after using them. For example:

In order to boot under classic BIOS emulation mode, you need to restore hybrid partition data on MBR using data in GPT by:

These tools are needed since bootloader in BIOS emulation mode need these MBR data.

{i} Some newer version of MacOS X diskutil program is supposed to update hybrid partition table. But use of diskutil may cause problem with partition type data such as Linux ext3. Thus it is safest to use parted and GPT synchronization tool in sequence to have correct hybrid partition table.

<!> Use of parted to update GPT partition will zap MBR and bootloader installed in it (/dev/sda). You need to run and GPT synchronization tool such as gptsync to have correct hybrid partition table. You also need to run "grub-install /dev/sda" to reinstall BIOS emulation grub-pc in it. It is safer to install bootoader in places such as /dev/sda3 to avoid overwriting.

(!) Use of gptsync and "grub-install /dev/sda" are compatible to each other.

Please note first partition is used by GPT table itself. Let's think following configuration:

Installed contents

Linux device name

Mac OS X device name

Grub legacy device name

Grub 2 device name

GPT

/dev/sda1

disk0s1

(hd0,0)

(hd0,1)

Mac OS X

/dev/sda2

disk0s2

(hd0,1)

(hd0,2)

Linux amd64

/dev/sda3

disk0s3

(hd0,2)

(hd0,3)

Linux i386

/dev/sda4

disk0s4

(hd0,3)

(hd0,4)

Data MSDOS (vfat)

/dev/sda5

disk0s5

swap

/dev/sda6

disk0s6

In order to boot though BIOS emulation provided by Apple, I wll deploy following boot sequence and partitioning here:

  EFI -> rEFIt --+--> Mac OS X (/dev/sda2)
                 +--> Lilo (replace with GRUB 2 later) - Linux amd64 (/dev/sda3)
                 +--> Lilo (replace with GRUB 2 later) - Linux i386  (/dev/sda4)

Install rEFIt to Mac OS X

EFI bootloader rEFIt is available from the rEFIt Project: http://refit.sourceforge.net/

The use of rEFIt is easiest for system maintenance. It provides proper BIOS emulation initialization (via proprietary Apple code) and can chainload BIOS compatible bootloaders located on MBR or on each partition.

Downloading "Mac disk image" under Mac OS X and follow instruction at: http://refit.sourceforge.net/doc/c1s1_install.html is easiest.

Install rEFIt from the rEFIt Project: http://refit.sourceforge.net/

{i} "bless" is the command to store location of EFI boot loader such as rEFIt to NVRAM and run by rEFIt installer.

Reboot it and check it works.

{i} Read the documentation "Myths and Facts About Intel Macs": http://refit.sourceforge.net/myths/

{i} You may as well get ready with GRUB bootloader CD now: grub-rescue-pc package for GRUB 2.

Shrink Mac OS X partition with diskutil

In order to make space for Linux, run following command to shrink Mac OS X partition from normal Mac OS X system:

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!

(When rebooting with rEFIt, always choose "Disk Partitioning and synchronize" to be safe.)

Then you have unused disk space. You may create some dummy partitions as DOS data partition now.

Install Debian lenny (basic)

/!\ Do not chose GRUB for bootloader during installation process. This is because d-i (lenny: RC2) is buggy ([http://bugs.debian.org/502446 Bug#502446]) and choses grub-pc on GPT machine. It will not function as expected if they are installed on partition such as /dev/sda3. (I did not install it on MBR /dev/sda).

You can do the same for /dev/sda4 too with adjustments.

{i} Recent rEFIt can be configured to boot non Mac OS X first by editing its configuration in Mac OS X.

Install Debian lenny (advanced: needs to be tested)

Here is more efficient install process.

{i} Although you are supposed to update /boot/grub/grub.cfg by /usr/sbin/update-grub using templates from /etc/grub.d and settings from /etc/default/grub, direct edit of this file is easy short term fix to have correct boot environment. Simplest one is like:

set root=(hd0,3)
menuentry "Debian GNU/Linux" {
        linux   /vmlinuz root=/dev/sda3 ro
        initrd  /initrd.img
}
menuentry "Debian GNU/Linux old" {
        linux   /vmlinuz.old root=/dev/sda3 ro
        initrd  /initrd.img.old
}

More on system configurations

Please refer to http://wiki.debian.org/MacBook for specifics.

-- OsamuAoki