Booting Linux inside a MacBook using grub and EFI
What follows applies only to MacBooks that contain an Intel CPU
(and not to the older PowerPC models).
There are two ways to boot a GNU/Linux operating system
installed inside an Apple MacBook.
- Use an emulated BIOS environment. This is usually called
boot camp and is what Apple designed so that
users could also install Windows alongside the Mac OS,
and setup their MacBook for a dual-boot.
- Use the EFI. MacBook do not employ a BIOS to boot the system,
but they use EFI. The latest GRUB has an EFI mode, so that it can
be used to boot Linux directly from EFI.
The following instructions explain what I did to boot
Debian and Ubuntu in my MacBook 5.1 using EFI.
You should also read:
(but note that they are outdated and/or different
than my experience, in many
points: e.g. in my experience the Nvidia 3D acceleration works fine,
contrary to what the Debian wiki says! and the virtual terminals
are OK when using nouveau).
Note that modern Intel CPUs can
run both 32bit and 64bit code (and that is called
i386 and amd64 in Debian and Ubuntu).
In older MacBooks EFI is started in 32bit mode,
in newer ones in 64bit mode.
The version of grub-efi that you install should be of the same
type. See into
http://grub.enbug.org/TestingOnMacbook for details.
Indeed nowadays Debian contains two packages
grub-efi-ia32 and grub-efi-amd64 for that reason.
For the MacBook 5.1 , I used the amd64 version.
According to some sources, the linux kernel that is then booted
should again be of the same type, otherwise it will not
be able to dialog with EFI correctly. I personally have booted
both without noticing problems.
I was able to boot succesfully the following O.S.:
- Debian/squeeze/i386
- Debian/wheezy/i386
- Debian/wheezy/amd64
- Ubuntu/lucid/amd64
By "succesfully" I mean that all hardware works fine, including
- built-in camera, (in Ubuntu/lucid and Debian/wheezy I did not even need
to exctract the firmware from the Apple drivers!)
- sleep (but rarely it may hang on wakeup),
- wireless
(note that in Debian/squeeze you need to install updated
drivers for the wireless card ; in Debian/wheezy, with
kernel 3.0, it works right away).
- video (works out of the box, I did not need to extract display settings and timings from the Mac OS)
- display backlight (works out of the box in Debian/wheezy, when X uses nouveau drivers,
and in Gnome you can use the two keys F1 F2 to adjust it)
booting Debian (and Ubuntu) into a MacBook 5.1 using grub2-efi
- Inside the Mac OS, install the program refit: this will
show a boot menu where you may then choose to chain-boot into
grub. Also, prepare partitions. Then install Debian or Ubuntu in some
partition. (I am not providing further instructions on this: see
the debian wiki.
AFAICR the first time, some years ago, I installed Debian/Lenny using
a CD and boot-camp mode, then I used 'debootstrap' to install all the
rest).
- Install needed packages and generate the
grub.cfg
# apt-get install grub-efi-amd64
# update-grub
- mount EFI partition
# mkdir /efi
# mount /dev/sda1 /efi
- move away previous attempts, if any, and create the directory
# mv /efi/efi/grub /efi/efi/grub.old
# mkdir /efi/efi/grub
- copy all stuff that http://grub.enbug.org/TestingOnEFI tells to copy
# cd /usr/lib/grub/x86_64-efi
# cp *.mod fs.lst command.lst /efi/efi/grub
- create EFI image
# grub-mkimage -O x86_64-efi -o /efi/efi/grub/grub.efi \
-p /efi/grub part_gpt hfsplus fat ext2 normal \
chain boot configfile linux multiboot
- copy /boot/grub/grub.cfg into /efi/efi/grub/
and possibly edit it to load the correct video driver, in my case
function load_video {
set debug=fb
insmod efi_gop
#insmod vbe
}
or otherwise use efi_uga on older MacBooks.
(Moreover, if your root partition
is crypted, you will need to copy the linux kernel and initrd
in a non crypted partition, say /efi/linuxboot,
and modify /efi/grub/grub.cfg consequently).
- In Debian/squeeze
it seems that nouveau drivers do not work in efi mode, blacklist them:
create a file
/etc/modprobe.d/efi_boot.conf
containing just
blacklist nouveau
In Debian/wheezy and Ubuntu/lucid , they are fine.
- In Debian/squeeze you may need to load some modules quite early
(in particular if you have a crypted root partition: otherwise
the keyboard will not work at the moment when the initrd will
ask you the password). To this end, append to the file
/etc/initramfs-tools/modules these lines:
#as suggested by http://grub.enbug.org/TestingOnMacbook
fbcon
#and I would further add
hid_apple
hid
applesmc
input_polldev
#moreover Vladimir 'phi-coder/phcoder' Serbinenko
#told me also to add
uhci_hcd
ehci_hcd
ohci_hcd
then regenerate the initrd
# update-initramfs -u
- Again, it seems that Debian/wheezy does not need those
(I have a crypted root partition, and I can enter the password
without problems).
- Using NVIDIA. The nouveau driver in Debian/wheezy works
fine, but does not provide (yet, at Sep 2011) any GL acceleration.
So I installed the nvidia stuff. There are two problems
with the nvidia stuff:
- once the X server starts,
if you type ctrl-alt-F? to go back to a
text consoles, it will be all pitch black;
- the screen backlight cannot be adjusted
(but, warning! if you change it, and you go into sleep mode and then
out, then it will be changed: so if you dim it too much,
and you sleep in/out, your screen will be pitch black!)
Disclaimer: the content of this page and the ones following
represent only the opinion and work of the author and not that of the
Scuola Normale Superiore.
Please pay a lot of attention. In May 1997 Italian parliament passed a
privacy law that makes it illegal to collect or trade information about
individuals or companies without their prior written approval; this
well
includes addresses, telephone numbers AND e-mail addresses.
Similair laws exist also in the U.S.A.: "By US Code Title 47,
Sec.227(a)(2)(B), a computer/modem/printer meets the definition of a
telephone fax machine. By Sec.227(b)(1)(C), it is unlawful to send any
unsolicited advertisement to such equipment. By Sec.227(b)(3)(C), a
violation of the aforementioned Section is punishable by action to
recover actual monetary loss, or $500, whichever is greater, for each
violation."
Since I am a USA national, I appeal also to these laws. I DO NOT GIVE
YOU MY CONSENT. YOU MUST DELETE ANY REFERENCE TO ME, IMMEDIATELY.
Regards, A. Mennucci