Re: Current status on grub-installer on PowerMac
On 4/14/21 1:45 PM, Mark Cave-Ayland wrote:
> 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 , 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  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 
>> (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.
The problem was simply that the HFS filesystem had to be unmounted before accessing
with hfsutils. It works now. Currently performing the final test.
>> 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
Not sure why to pass "-c chrp" here as all the instructions I have seen for
PowerMac pass "-c UNIX".
> 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?
Seems so. See the grub-install source code.
> 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
I'm just using the path provided by "opathname" as this way we can install onto any type
of media instead of just hard disks.
>> And, finally, GRUB's grub-install never substitutes the variable names "device"
>> and "partition" in the boot script  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.
Ah, I wasn't aware of that.
> 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.
I can try removing the sed command from grub-installer again and see if that still works.
Currently, I have:
sed -i 's!&device;:&partition;!'"$ofpath"'!g' $ROOT/boot/grub/System/Library/CoreServices/BootX
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer - email@example.com
`. `' Freie Universitaet Berlin - firstname.lastname@example.org
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913