On 4/10/22 00:30, Thomas Schmitt wrote:
Hi,
Nikolay Nikolov wrote:
I haven't looked at GRUB's MBR code, but there's enough space in the MBR to
scan the GPT entries, find a specific GUID partition type and load the first
several kilobytes from it and transfer control to it.
Well, GRUB goes a different way on legacy BIOS. It boots its core code
without knowing about partitions and then loads the modules which its
configuration expects to need. I understand GPT is handled by "part_gpt"
and MBR partitions by "part_msdos".
The code takes up only 262 bytes so far
It is astounding what can be squeezed into 440 bytes of x86 machine code.
Maybe I should try adapting my code, so that it finds the GRUB BIOS boot
partition and loads it? It shouldn't be too hard to do, the main
obstacle is that I'm not familiar with GRUB's code and I don't know what
GRUB's next stage needs (i.e. at what address it should be loaded, and
how it should be called). But regarding size, core.img is apparently
less than 32 kb, and it fits between the MBR and the first partition on
MBR systems, and my code already loads almost 64kb from a GPT partition,
so even if the next GRUB stage needs some special requirements (like
moving to a different address, enabling gate A20, entering protected
mode, etc), it can be done at least with a wrapper, but perhaps also
even in the remaining bytes of my MBR code.
-----------------------------------------------------------------------
I meanwhile learned that the El Torito boot image eltorito.img used by
grub-mkrescue is not a plain copy of cdboot.img but rather a
concatenation of cdboot.img and a core.img :
https://www.gnu.org/software/grub/manual/grub/grub.html#Making-a-GRUB-bootable-CD_002dROM
"For booting from a CD-ROM, GRUB uses a special image called cdboot.img,
which is concatenated with core.img. The core.img used for this should
be built with at least the ‘iso9660’ and ‘biosdisk’ modules."
So the role of the BIOS partition is properly fulfilled by the El Torito
boot image which has 27874 bytes in my example ISO from grub-mkrescue.
Unfortunately, I'm not familiar with how El Torito works, I only
understand the legacy PC boot process from floppy/hard disk/USB flash
drive, but not from optical media. This hybrid USB stick/DVD iso image
has always seemed like black magic to me :) And we've been spoiled and
expect it to work, but I think it doesn't work with Windows 10, for
example. :) AFAIK, Windows only provides an ISO download, that is
suitable for burning on optical media and then it boots, but it doesn't
work, when you "dd" it to an USB flash drive. I think you need to use
special tool, to write it to a USB stick, but I've never done it, I
still burn DVD+R for Windows installs :) And what's worse, they now
require the rarer and more expensive DVD+R DL discs, since their install
image exceeds 4.7 GB :)
Have a nice day :)
Thomas
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure