Differences between revisions 23 and 24
Revision 23 as of 2008-11-03 14:50:53
Size: 10143
Editor: OsamuAoki
Comment:
Revision 24 as of 2008-11-03 14:53:44
Size: 10159
Editor: OsamuAoki
Comment:
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:
There is a modified lenny beta 2 netinst installer CD image at : http://people.debian.org/~osamu/ as d-i-osamu-grub2.iso with the corrected grub-installer package. (See [:Modify/CD:] how I did this with diunpk and dipk.) There is a modified lenny beta 2 netinst installer CD image at : http://people.debian.org/~osamu/ as d-i-osamu-grub2.iso with the corrected grub-installer package. (See [:DebianInstaller/Modify/CD:] how I did this with diunpk and dipk.)

Debian Install Tutorial for MacBook

Here I describe simple tutorial to install Debian on Macbook. (initially written for lenny beta2 CD on 2008-11-01, using MacBook Core2 Duo Japanese model but applicable to other locales)

(!) 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.

There are 3 major issues with current lenny beta 2 CDs for MacBook:

There is a modified lenny beta 2 netinst installer CD image at : http://people.debian.org/~osamu/ as d-i-osamu-grub2.iso with the corrected grub-installer package. (See [:DebianInstaller/Modify/CD:] how I did this with diunpk and dipk.)

?TableOfContents(4)

MacBook installation prerequisites

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

MacBook has few special keys:

  • delete = PC's BS
  • Fn + delete = PC's Del
  • Fn + F1 = PC's F1
  • Fn + F2 = PC's F2
  • ...
  • Fn + F12 = PC's F12

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 system 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 classic bootloaders used under 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)

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 boot system -> rEFIt program ->+
    +<-------------------------------+
    +--> Mac OS X      on /dev/sda2 (by rEFIt directly)
    +--> Linux testing on /dev/sda5 (via GRUB 2 MBR located on /dev/sda)
    +--> Linux amd64   on /dev/sda3 (via GRUB 2 BR  located on /dev/sda3)
    +--> Linux i386    on /dev/sda4 (via GRUB 2 BR  located on /dev/sda4)

GRUB 2 boot loader from BIOS emulation is grub-pc which can access any GPT partition. It looks like 3 places to put BIOS compatible boot record. (Do not install boot record used by this BIOS emulation in /dev/sda1 nor /dev/sda2. I do not know the side effect.)

Install rEFIt to Mac OS X

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

The use of rEFIt makes system maintenance easy. It provides proper BIOS emulation initialization (via proprietary Apple code) and can chainload another BIOS compatible bootloaders, such as grub-pc, 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.

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

Reboot system and check rEFIt 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

/!\ 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 manually: 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 os-prober"

  • run gptsync in chroot: "gptsync /dev/sda"

  • fix wrong device names in 30_otheros created by buggy grub-installer package: "vim /etc/grub.d/30_otheros"

  • update GRUB2 config in chroot: "update-grub"

  • install GRUB2 into any BIOS compatible partition in chroot: "grub-install /dev/sda3" (or /dev/sda, or /dev/sda4)

{i} Recent rEFIt can be configured to boot non Mac OS X first by editing its configuration in Mac OS X at: /efi/refit/refit.conf

{i} When booting with GRUB, your keyboard will act like US keyboard.

<!> Buggy "/etc/grub.d/30_otheros" created by buggy grub-installer package contains entries such as "set root=(hd0,2)" for a menu entry associated with "/dev/sda3". This offset of 1 is caused by [http://bugs.debian.org/502446 Bug#502446]. Simply change it to "set root=(hd0,3)" etc.. You must run update-grub after this to activate this. If os-prober is installed as above example, you may erase this buggy file as alternative.

{i} If you did not fix "/etc/grub.d/30_otheros" as above, you can still edit in interactive the GRUB menu by pressing "e".

Recap

  • Install gptsync, grub-pc and os-probe at least
  • Whenever you update partition, you must update:
    • run gptsync in chroot console
    • run update-grub in chroot console
    • run grub-install /dev/sda (if you wish to boot from MBR) in chroot console
  • MBR on /dev/sda may be erased by other tools such as parted.
  • grub-installer is buggy for grub-pc when GRUB 2 (grub-pc) is installed to non-MBR.
  • Some GRUB menu entries may require manual bug fixing during booting.

(!) Have USB connected keyboard ready. Keyboard on MacBook acts funny under some condition. Beta2 under BIOS emulation did not require this..

(!) Some people say that use of the following voodoo phrase as kernel boot parameters is a good idea but I did not need this for i386 and amd64 install via rEFIt using BIOS emulation:

install noapic irqpoll acpi=force

Booting system (emergency)

(!) Booting while pressing "C" key forces system to boot with CD/DVD first before poking HDD. (Use this you really broke system and re-installing Mac OS X.

If grub can be started, linux installed in /dev/sda4 can be started by providing followings to grub shell:

set root=(hd0,4)
linux /vmlinuz root=/dev/sda4 ro
initrd initrd.img

More on system configurations

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

-- OsamuAoki