Search:  
Gentoo Wiki

Apple_MacBook/MacOSX_dual_boot

Contents

Introduction

A friend needed linux on his new MacBook Pro laptop for two courses, and since right now there are no EFI capable distros, I decided to try and install Gentoo for him. I will detail how it was possible to install Gentoo on it, but be warned, this isn't a clean way of doing it. I will try to fix it up soon, but until then, here it goes...

Note: Successes with Debian have also been reported.

Step 1 : Preparing

Download the following files from the Mactel Project :

config-2.6.16
imac-2.6.16.1.patch or imac-2.6.16.1.patch (depends on what kernel sources you want to use)
xorg.conf
Note: The patch is necessary for elilo.

We also need another file, but it will come from the next part

Step 2 : Booting

Before we can install Gentoo, we need to be able to boot on the MacBook, to do this, download the LiveCD created by the Mactel Project. I had to run the dhcp client manually once the cd booted to be able to access the network :

dhcpclient eth0

Now mount a usbkey and copy the file /mnt/initrd/newroot/mnt/cdrom/efi/elilo/e.efi on it. We will need this later on to boot Gentoo.

Step 2 : Install Gentoo

I just followed the instructions in the handbook, except for 2 of them :

Kernel and Bootloader

I will explain these out in detail next. Format your partitions.

Tip: Where ext2/3 should work out of the box, you may need to modprobe the drivers for other filesystems.

Step 3 : The kernel

This is the first tricky part, the default kernel doesn't boot on the MacBook, so you have to patch it with the patch retreived from Step 1. Here is what I did :

Code: kernel 2.6.16 install

We need a kernel 2.6.16 kernel

echo "sys-kernel/gentoo-sources ~x86" >> /etc/portage/package.keywords
emerge -v --fetchonly gentoo-sources

We need to patch the kernel, and remove a patch, so copy these files and uncompress them

cp /usr/portage/distfiles/linux-2.6.16.tar.bz2 /root
cp /usr/portage/distfiles/genpatches-2.6.16-2.extras.tar.bz2 /root
tar jxvf linux-2.6.16.tar.bz2
tar jxvf genpatches-2.6.16-2.extras.tar.bz2

Next, remove this patch, it keeps the new one from being applied

rm 2.6.16/4205_vesafb-tng-1.0-rc1-r3.patch

Now patch the kernel, to do this, we need to rename it first and then restore it after the patching is done

mv linux-2.6.16 linux-2.6.16-rc6
patch -p0 < imac-2.6.16.patch
mv linux-2.6.16-rc6 linux-2.6.16

Then recompress the newly patched kernel and the other patches

tar cvf linux-2.6.16.tar linux-2.6.16
bzip2 linux-2.6.16.tar
tar cvf genpatches-2.6.16-2.extras.tar 2.6.16
gzip2 genpatches-2.6.16-1.extras.tar

We may now copy the two files back where they came from

cp linux-2.6.16.tar.bz2 /usr/portage/distfiles 
cp genpatches-2.6.16-2.extras.tar.bz2 /usr/portage/distfiles

Now we have to rebuild the digest/manifest

ebuild /usr/portage/sys-kernel/gentoo-sources/gentoo-sources-2.6.16 digest

At last let's install and compile the kernel, I did this with Kernel/genkernel, a manual build should also work, but I didn't try. We will use the Mactel Project's config file.

emerge -v gentoo-sources
cp config-2.6.16 /usr/share/genkernel/x86/kernel-config-2.6
genkernel all

If you really wanted reiserfs support, configure it before, using the --menuconfig flag with genkernel, I didn't test this.

Once the kernel is compiled, we need to copy it and the initrd on a usb stick to later be able to boot, so copy /boot to the usb stick.

Now reboot to MacOS X

Step 4 : The Boot loader

Now let's configure the dual boot. I originally tried elilo, but I ran into some problems. I decided to use rEFIt instead.

I downloaded the file and uncompressed it. Then I copied the efi folder to the root of the disk using the terminal

cp -R efi /

then create a folder named linux in the efi folder

mkdir /efi/linux

Now copy the e.efi, kernel and the initrd files that you copied to the usbstck into the /efi/linux directory. Rename the kernel to vmlinuz and rename the initrd image to initrd.gz

cd /efi/linux
mv kernel-genkernel-x86-2.6.16-gentoo vmlinuz
mv initramfs-genkernel-x86-2.6.16-gentoo initrd.gz

Create a file named elilo.conf containing the following

File: /efi/linux/elilo.conf
chooser=simple
legacy-free

delay=20
prompt
default=gentoo

image=vmlinuz
	label=gentoo
	description="Gentoo 2006.0"
	initrd=initrd.gz
	read-only
	append="video=imacfb:i17 acpi=force libata.atapi_enabled=1 root=/dev/ram0 real_root=/dev/sda4 gpt"

where real_root is the root of your linux installation (i.e. /)

Now execute the enable-always.sh script in the /efi/refit

cd ../refit
./enable-always.sh
Note: If you create multiple entries in the boot loader, a bug present in the firmware on MacBook Pro rev2 systems prevents the keyboard from working reliably. Unless Apple repairs the bug the only known workaround is to plug in an external USB keyboard and use it to select the alternate boot images.

And that's it! Now reboot and enjoy!

Step 5 : Xorg

Install xorg using portage and use the xorg.conf file that you copied at the very begining, just copy it to your /etc/X11 directory.

cp xorg.conf /etc/X11

and voila :-)

Problems

Everything seams to work, although I'm not sure about all the powermanagment stuff. I have an issue with the touchpad under X, it doesn't work right, so I used an external mouse instead. The keymap isn't correct, since it's for PCs and not Macs, I'm working on making one for the Swiss French keyboard, I'll post it once it's done. I use the US PC keymap right now.

Note: This is actually due to kernel module issues. Nothing is really "broken", but if certain kernel modules are compiled in OR loaded out of order (which they are by default) then you will experience touchpad and keyboard issues.

Conclusion

This was fun to do and it proved to be very useful :-) Until an EFI Gentoo kernel and official Bootloader is created, this should help some people. I still need to clean this up some though... --High (Gabriel Rossetti) 20:47, 28 March 2006 (GMT)

Links

Retrieved from "http://www.gentoo-wiki.info/Apple_MacBook/MacOSX_dual_boot"

Last modified: Fri, 29 Aug 2008 00:53:00 +0000 Hits: 27,358