[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Current status on grub-installer on PowerMac

On 14/04/2021 08:54, John Paul Adrian Glaubitz wrote:


I have been working on getting the GRUB installation on PowerMacs fixed the
past days which turned out to be far more tricky than I expected. As can be
seen from the number of test images I have created so far [1], I have already
been through quite a number of image rebuilds to get the grub-installer work
correctly on PowerMac (ignore the timestamps in the folder names, the correct
timestamps of the images can be seen from the creation date in the folder view).

Great work Adrian!

The latest image is in the folder "hfstest-20210411-8" which I created this
morning. This image is not tested yet, but it should actually work when looking
at the script code itself [2] but it doesn't which is most likely attributed to a
race condition.

The problem is that setting the correct file properties with the hattrib tool
fails at the first attempt of installing the bootloader but succeeds when just
reattempting to install the bootloader from the installer menu. So far, I have
not been able to find out why, that will require more debugging.

If anyone wants to give it a try themselves, please fetch the image from [1]
(so far I created a 32-bit image only) and see if it works for you.

Note: After selecting the partition layout, the partioning tool will present
an empty question dialog which should be answered with <NO>. It's a known issue
I will fix later, so just ignore it for now.

FWIW, I also found a number of bugs in GRUB on PowerMac itself while working
on the problem. It turns out that GRUB does not set the proper openfirmware
path in NVRAM pointing to the BootX script that it just installed. The script
gets installed into :System:Library:CoreServices:BootX but grub-install (the
upstream GRUB installation tool) just sets the path to :BootX.

I would expect this to work since BootX is simply the filename and so it is a relative path reference, presumably to the blessed CoreServices directory. Otherwise you'd end up using an absolute path in the form \path\to\BootX.

Also, while GRUB's grub-install blesses the "CoreServices" folder, it does
not set the "tbxi" attribute which means it's not possible to boot the disk
with "boot hd:N,:\\tbxi" (N being the partition).

That should be an easy fix now that you've got hattrib working:

    hattrib -t tbxi -c chrp path/to/BootX

I'm curious as to how grub-install currently handles the blessing of the CoreServices directory for different filesystems - does it only attempt to bless the folder if it detects a HFS/HFS+ filesystem?

Finally it may be worth noting that if you omit the partition number then the firmware will locate the first bootable partition itself which is the default value that OpenBIOS uses, e.g.

    boot hd:,\\:tbxi

And, finally, GRUB's grub-install never substitutes the variable names "device"
and "partition" in the boot script [3] it installs. They just remain as is on
the disk which naturally means that grub-install currently cannot itself properly
install GRUB on a PowerMac which is obviously a bug.

This shouldn't be needed. Having a look at grub.chrp.in from your link and ofboot.b on some old Fedora ISOs I have lying around, these files are all CHRP boot scripts i.e. XML surrounded by <CHRP-BOOT>...</CHRP-BOOT> tags.

IIRC it is part of the CHRP boot specification that the firmware substitutes the values for "&device;" and "&partition;" in <BOOT-SCRIPT>...</BOOT-SCRIPT> when reading the CHRP boot script into memory, and that's certainly what OpenBIOS does.

I guess the real question is does Apple's OF do the right thing here? My feeling is that it does, since grub.chrp.in uses the hard-coded path \System\Library\CoreServices\grub.elf which is a directory that only exists if grub is installed on a MacOS computer.



Reply to: