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 (I did not need this for i386 install):
install noapic irqpoll acpi=force
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:
- parted: GNU/Linux
- diskutil: MacOS X (pre-10.4.6 Mac OS X requires this.)
In order to boot under classic BIOS emulation mode, you need to restore hybrid partition data on MBR using data in GPT by:
- gptsync: GNU/Linux (both on i386 and amd64 now for lenny)
- boot menu of rEFIt to choose "Disk Partitioning and synchronize"
These tools are needed since bootloader in BIOS emulation mode need these MBR data.
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) |
Linux testing |
/dev/sda5 |
disk0s5 |
N/A |
(hd0,5) |
Data MSDOS (vfat) |
/dev/sda6 |
disk0s6 |
N/A |
(hd0,6) |
swap |
/dev/sda7 |
disk0s7 |
N/A |
(hd0,7) |
In order to chain boot though BIOS emulation provided by Apple, I will deploy following boot sequence and partitioning here:
EFI -> rEFIt --+
+------------+
+--> Mac OS X on /dev/sda2 (via rEFIt)
+--> Linux testing on /dev/sda5 (via GRUB 2 MBR on /dev/sda)
+--> Linux amd64 on /dev/sda3 (via GRUB 2 BR on /dev/sda3)
+--> Linux i386 on /dev/sda4 (via GRUB 2 BR on /dev/sda4)GRUB 2 boot loader from BIOS emulation is grub-pc which can access any GPT partition. It looks like at least 3 reasonable place to put BIOS compatible boot record. Other 2 locations /dev/sda1 and /dev/sda2 may be used but untested.
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/
"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.
Read the documentation "Myths and Facts About Intel Macs": http://refit.sourceforge.net/myths/
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
Do not chose to install GRUB into partition 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. It works with MBR (/dev/sda) but MBR is risky since it will be zapped by running parted.
Here is an example of efficient install process.
- boot with Debian lenny installer CD.
- partition as required root=/dev/sda3, swap=/dev/sda6 . (or root=/dev/sda4, root=/dev/sda5, ...)
- install system to /dev/sda3 (or /dev/sda4 or /dev/sda5 ...)
- install GRUB to MBR (/dev/sda) or not to install GRUB here
- CD may pop out but do not reboot yet.
- open shell: Alt-F2, Alt-F3, or from menu (You may need to press Fn with F2)
chroot into target: "chroot /target"
install programs to HDD in chroot: "aptitude install gptsync grub-pc vim mc parted"
gptsync: "gptsync /dev/sda"
update GRUB2 config: "update-grub"
edit/chack GRUB2 config: "vim /boot/grub/grub.cfg"
install GRUB2 into reasonable partition: "grub-install /dev/sda3" (or /dev/sda4 or /dev/sda)
Recent rEFIt can be configured to boot non Mac OS X first by editing its configuration in Mac OS X.
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 if auto detection code or grub installation code is broken. Simplest one looks 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
}
Recap
Whenever you update partition, you must update:
- run gptsync
- run grub-install /dev/sda (if you wish to boot from MBR)
- MBR on /dev/sda may be erased by other tools such as parted.
- debian-installer is buggy for installing GRUB 2 (grub-pc) to non-MBR
More on system configurations
Please refer to http://wiki.debian.org/MacBook for specifics.
-- OsamuAoki
