Booting a Macbook Pro 2006

Hi all,

Resurrected an old MacBook Pro 2006 2,33Ghz Core 2 Duo (macbookpro2,2 as Apple names it) who’s getting dust since more than 4 years, I decided to give Linux a try and successfully installed openSUSE Leap 15.1 on it which support the best this oldie (a couple of things need to be fixed like suspend/hibernation when closing the lid, kde plasma lags sometimes when it comes to move windows or scroll, a logout fixes temporarily, etc.), but overall an impressive work from opensuse’s developpers, kudos!

But I couldn’t find a way to boot it without the help of x86_64 install DVD and/or without refind/refit.
Some folks (here and there) are stating it’s possible to boot directly from EFI right from Apple’s bootloader (when holding the alt/option key at startup).
As this laptop has a 32-bit EFI but its cpus are 64-bit and I don’t know if its the culprit nor if these steps are exclusively for Debian/Ubuntu.

I’m using the simple following partition scheme with an ESP formatted in FAT32:

fdisk -l
Disk /dev/sda: 119.2 GiB, 128035676160 bytes, 250069680 sectors
Disk model: M4-CT128M4SSD2  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 51451770-8540-45EA-B2E1-2001B1CA18E9

Device         Start       End   Sectors  Size Type
/dev/sda1       2048    503807    501760  245M EFI System
/dev/sda2     503808 243773439 243269632  116G Linux filesystem
/dev/sda3  243773440 250069646   6296207    3G Linux swap


gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sda: 250069680 sectors, 119.2 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 51451770-8540-45EA-B2E1-2001B1CA18E9
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 250069646
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          503807   245.0 MiB   EF00  
   2          503808       243773439   116.0 GiB   8300  
   3       243773440       250069646   3.0 GiB     8200  


Am I stuck with using refind/refit (which add another booting step) or can I boot grub2 directly with the help of grub2-i386-efi?

I am booting a KVM virtual machine with grub2-i386-efi. But it has nothing to do with Apple. Yes, Leap 15.1 boots fine that way. I’m currently running Leap 15.2 in that virtual machine.

Unfortunately, Leap 15.2 and 15.1 do not know about grub2-i386-efi, though they do provide the package. So I have it configured for traditional MBR booting (boot from a partition). I cannot actually boot it that way, but it is configured for booting that way so as to keep the software happy. When you have it up and running, install grub2-i386-efi. And then run

grub2-install --target=i386-efi

grub itself supports installing 32 bit EFI on 64 bit Linux (it even autodetects necessary platform). But SUSE bootloader management tools force grub platform to be the same as Linux platform. So it may work, but on grub package update only 64 bit version will be updated, you will need to refresh 32 bit manually.

It would be quite helpful if you reported your experience.

Thanks for your suggestion @nrickert!
After installing grub2-i386-efi, the following layout has been created on the ESP FAT formatted partition (/dev/sda1 mounted on /boot/efi):

# ls -al /boot/efi/
total 8
drwxr-xr-x 1 root root    5 Jun  4 05:00 .
drwxr-xr-x 4 root root 4096 Jun  3 22:17 ..
drwxr-xr-x 1 root root    3 Jun  4 05:00 EFI
# ls -al /boot/efi/EFI/
total 0
drwxr-xr-x 1 root root 3 Jun  4 05:00 .
drwxr-xr-x 1 root root 5 Jun  4 05:00 ..
drwxr-xr-x 1 root root 7 Jun  4 05:39 opensuse
# ls -al /boot/efi/EFI/opensuse/
total 196
drwxr-xr-x 1 root root     7 Jun  4 05:39 .
drwxr-xr-x 1 root root     3 Jun  4 05:00 ..
-rwxr-xr-x 1 root root 90624 Jun  4 05:02 grub.efi
-rwxr-xr-x 2 root root 90624 Jun  4 05:02 grubia32.efi

After that, putting

GRUB_USE_LINUXEFI="true"

in /etc/default/grub, booting with the help of the install DVD, grub2 starts in efi mode and /boot/grub2/grub.cfg is executed with proper menu enries. Good point :slight_smile:

Next step is to make grub2 efi mode started right away from Apple’s EFI bootloader (bypassing the not-so-useful refind/refit), which is what I achieved (read below my answer to @arvidjaar if you know how I’ve done this).

Thanks too @arvidjaar for replying!

Indeed. But the important part to make grub2 starting directly from Apple’s EFI bootloader (by holding down the alt/option key at laptop’s startup) is turning the ESP FAT formatted partition /dev/sda1 (mounted in /boot/efi) into an HFS+ partition (with the help of this article and this one (thanks to Jason Heeris and Mike Hommey)).

To achieve this, installing hfsutils and diskdev_cmds to format in HFS+ the ESP on gdisk(8).
Once the ESP is an HFS+, running again:

grub2-install --target=i386-efi --bootloader-id=opensuse

creates the following layout:

# ls -alR /boot/efi/
/boot/efi/:
total 8
drwxr-xr-x 1 root root    5 Jun  4 05:00 .
drwxr-xr-x 4 root root 4096 Jun  3 22:17 ..
drwxr-xr-x 1 root root    3 Jun  4 05:00 EFI
-rw-r--r-- 1 root root   33 Jun  4 04:59 mach_kernel

/boot/efi/EFI:
total 0
drwxr-xr-x 1 root root 3 Jun  4 05:00 .
drwxr-xr-x 1 root root 5 Jun  4 05:00 ..
drwxr-xr-x 1 root root 7 Jun  4 05:39 opensuse

/boot/efi/EFI/opensuse:
total 196
drwxr-xr-x 1 root root     7 Jun  4 05:39 .
drwxr-xr-x 1 root root     3 Jun  4 05:00 ..
drwxr-xr-x 1 root root     3 Jun  4 05:00 System
-rw------- 1 root root  6469 Jun  4 05:39 grub.cfg
-rwxr-xr-x 1 root root 90624 Jun  4 05:02 grub.efi
-rwxr-xr-x 2 root root 90624 Jun  4 05:02 grubia32.efi
-rw-r--r-- 1 root root    33 Jun  4 05:05 mach_kernel

/boot/efi/EFI/opensuse/System:
total 0
drwxr-xr-x 1 root root 3 Jun  4 05:00 .
drwxr-xr-x 1 root root 7 Jun  4 05:39 ..
drwxr-xr-x 1 root root 3 Jun  4 05:00 Library

/boot/efi/EFI/opensuse/System/Library:
total 0
drwxr-xr-x 1 root root 3 Jun  4 05:00 .
drwxr-xr-x 1 root root 3 Jun  4 05:00 ..
drwxr-xr-x 1 root root 4 Jun  4 05:04 CoreServices

/boot/efi/EFI/opensuse/System/Library/CoreServices:
total 96
drwxr-xr-x 1 root root     4 Jun  4 05:04 .
drwxr-xr-x 1 root root     3 Jun  4 05:00 ..
-rw-r--r-- 1 root root   383 Jun  4 05:02 SystemVersion.plist
-rwxr-xr-x 2 root root 90624 Jun  4 05:02 boot.efi

NB. /boot/efi/mach_kernel, /boot/efi/EFI/opensuse/mach_kernel are dummy files (created as Jason Heeris and Mike Hommey suggested) and /boot/efi/EFI/opensuse/System/Library/CoreServices/SystemVersion.plist (created by hfs-bless from mactel-boot) to trick Apple’s EFI bootloader to show the ESP.
The /boot/efi/EFI/opensuse/grub.cfg has been copied by hands from /boot/grub2/grub.cfg as from what I have understand from Rob Smith’s excellente grub page (author of refind).

After these steps, grub2 is started directly from Apple’s EFI bootloader and reads /boot/grub2/grub.cfg (or /boot/efi/EFI/opensuse/grub.cfg…) but couldn’t load the initial ramdisk and efibootmgr(8) can’t be used on laptops having a 32-bit EFI:

# efibootmgr 
EFI variables are not supported on this system.

Sure, I will report my experience to this thread and once things are set up I will provide a step by step :slight_smile:

There’s no need to do that. You only need that for secure-boot, and openSUSE does not support secure-boot for 32-bit efi.

And thanks for the interesting info on booting an Apple. It is evidently different from booting the KVM virtual machine I use to test 32-bit efi. On that system, “efibootmgr” works fine. I think that has to do with how the kernel connects with the firmware during bootup. And Apple firmware is different from what other systems use. My virtual machine is using the OVMF virtualized firmware.

Indeed, I have just tried without:

GRUB_USE_LINUXEFI="true"

in /etc/default/grub and still grub2 starts in efi.

To clear up things, I tried the same steps on a more recent Apple laptop (MacBookPro9,2 which has a 64-bit EFI) and grub2 is able to boot fine openSUSE so it seems we can’t boot Linux by just relying on grub2 efi and the need of refind/refit is mandatory on those 32-bit EFI laptops :\

Well there’s a hope in booting a 64-bit kernel based from a 32-bit EFI with the help of eficross, available since Linux >=3.4. Right now it’s completely beyond my knowledge to do it nor knowing if it’s doable with openSUSE (tip found at ubuntu’s help page in second §5) but if I succeeded I will report in this thread.

Edit. here are the changes to the kernel authored by Linus: https://git.drk.sc/Derecho/irc-sbc-linux/commit/f06fc0c0de0b4f01dbad8ec5552e78192c7abbb8

I have stopped trying getting a 64 bits linux kernel booting from a 32 bits EFI (still haven’t tested eficross option because I don’t know how to make it works to this day) but have succeeded on getting i586 Tumbleweed (working better on that laptop than numerous of others distributions and *BSD) booting right from EFI.

If there’s people interested on how to achieve that, I will write down a complete how-to.