On 14/04/2021 12:53, John Paul Adrian Glaubitz wrote:
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.
Excellent!
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".
(goes and looks)
From what I can see there is a mixture of creator types: chrp is mentioned for
FreeBSD and BootX, whilst most of the grub references suggest using UNIX. Having a
look around the OpenBIOS code I think the creator type is only used in the absence of
a blessed directory, so either will do fine.
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 [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.
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
Out of curiosity did it still work when you removed this?
ATB,
Mark.