[syslinux] Getting classic BIOS and UEFI boot on the same disk?

Ady Ady ady-sf at hotmail.com
Thu Aug 22 10:53:47 PDT 2019


> > Do you want to build an image for an internal HDD that could be
> > capable of booting in both, BIOS mode and UEFI mode?
> 
> Yes. This would make us independent from the BIOS boot mode.
> 
> > Or, is this for a portable (USB) device?
> 
> Maybe - would be nice if this would work, but not required.

(snip)
 
> > Additionally, what OS(es) are you planning to boot from Syslinux (in
> > either BIOS mode and/or UEFI mode)?
> Linux. 32 bit (and 64 bit if this alternative is possible). Vanilla
> kernel + Linux from scratch.
> 
> > Is the resulting image expected to support multiple OSes? Which ones
> > (e.g. Windows, Linux)?
> 
> Linux - as written above 32 and 64 bit but not at the same time of
> course. So one image for 32 bit and one for 64 bit. No boot option to
> choose. No Windows, nothing else.
> 

Considering the above requirements, having a BIOS+UEFI HDD image 
booting with Syslinux should be possible. Well, at least in theory, 
because in practice, there are several additional items to consider.

Let's start by your first doubt (according to your initial email): 
whether to use MBR, or GPT instead.

UEFI systems are supposed to support booting disks that are partitioned 
in either GPT or MBR schemes. The potential problem is that, in 
practice, some UEFI implementations might not behave as expected by the 
UEFI specs, failing to boot in UEFI mode when using MBR. In other 
words, they are not completely UEFI-compliant.

Having said that, considering that you want to install Linux on your 
target hardware, and such intention should be tested, in the same way 
you should test whether this same hardware includes a (UEFI) firmware 
that supports booting MBR schemes in UEFI mode.

If the firmware is really UEFI-compliant, and if the (booting) HDD is 
not bigger than 2TB (although, under specific conditions, we could 
extend the limit), then probably MBR would be preferable, in order to 
support both firmware modes (BIOS and UEFI).

If MBR is not an option (whether because of crappy UEFI implementation, 
or because of the size of the booting HDD), then GPT is still possible. 
Since you want to support BIOS mode, then the "protective MBR" could 
use/be Syslinux's "gptmbr.bin". Please note that older versions of 
"gptmbr.bin" are different than newer ones (4.00+).

In any case, the boot partition should remain within the BIOS limits. 
Locating the boot partition after the first 2TB will generate problems 
in BIOS mode.

Talking about the boot partition, I would suggest that the boot 
partition for BIOS mode would/should rather be the same partition that 
is designated as "ESP" for UEFI mode. This boot partition/ESP should be 
formatted as FAT32. To be clear, strictly speaking these are not 
absolute conditions/requirements, but they do simplify the goal of 
BIOS+UEFI boot capability.

Within the boot partition, SYSLINUX for BIOS mode should be installed 
to the "/BOOT/SYSLINUX/" directory, and the c32 modules for BIOS should 
also be copied to the same location.

Within the "ESP", "efi64/syslinux.efi" should be copied to 
"EFI/BOOT/BOOTX64.EFI" and the corresponding c32 modules should be 
copied to the same directory.

Within the "ESP", "efi32/syslinux.efi" should be copied to 
"EFI/BOOT/BOOTIA32.EFI" and the corresponding c32 modules should be 
copied to the same directory.

Regarding the configuration file for each Syslinux 
variant/flavor/platform (and considering the prior paragraphs), these 
should be:

_ for BIOS: "/BOOT/SYSLINUX/SYSLINUX.CFG";

_ for UEFI X64: "/EFI/BOOT/SYSLX64.CFG" (6.04-pre1+);

_ for UEFI IA32: "/EFI/BOOT/SYSLIA32.CFG" (6.04-pre1+).

The above are (just) the "basics", but I should point out that there 
are more-than-a-few caveats, notes, warnings, enhancements, 
optimizations and limitations.

I would also suggest searching the Syslinux wiki. I'm not saying it is 
completely up-to-date, nor that every single piece/bit of information 
is covered, but people can use it as a starting point.

Regards,
Ady.



More information about the Syslinux mailing list