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

Thomas Schmitt
Wed, 21 Aug 2019 18:06:54 -0000

Hi,

only speaking theoretically from the disk view, as i'm not SYSLINUX expert
but rather provide a program to pack up bootable ISO 9660 images,
Ady surely has more experience with installation, but since he did not
mention the following facts, i add my two cents.

Erik Rull wrote:
> we would like to generate an image for our different
> hardware parts that supports both - classic BIOS boot and (U)EFI boot

This combination is present in many GNU/Linux installation ISO 9660
images which work from DVD and from USB stick. But because of a
shortcomming in SYSLINUX EFI with booting from optical media, the EFI
equipment is GRUB2, except Knoppix 8, which fails accordingly from DVD
via EFI. From USB stick it works fine.
Most x86 firmwares interpret USB sticks and hard disks identically.

So, since you seem to speak of hard disk images, if there is a problem,
then only with the installation software, not with the goal.


> I read some articles on how to install each version - from that I would
> carefully say that this is not possible...

Care to share the links ?


> The biggest gap seems to be the MBR and the GPT...

GPT specifies as block 0 a "Protective MBR" which is allowed to
contain
BIOS boot code. The constraint given by GPT is in respect to the partition
table, which may only contain a single partition, which must have type 0xee
and cover the whole disk from block 1 up to the last block.

But EFI does not demand GPT. It specifies as alternative an MBR partition
table layout with one partition of type 0xef and possibly more partitions.
The 0xef partition must not have the Boot/Active flag set.

BIOS does not directly demand partitions, but many MBR boot programs look
for a partition with Active/Boot flag in order to chainload the boot loader
found there. (ISOLINUX "isohdp[fp]x*.bin" do not look for the flag.)

  https://wiki.syslinux.org/wiki/index.php?title=Install#UEFI
mentions special MBR boot code images "gptmbr*.bin" for GPT but does
not say
much about how to install them.
Further it says:
  There are no "installers" for syslinux.efi. Copy the relevant
syslinux.efi
  file to an appropriate location, and rename it if necessary or desired.
  Additionally, copy the necessary core module file (either
"ldlinux.e32" or
  "ldlinux.e64", according to the architecture of the firmware) to the
same
  directory.
This looks like you are supposed to create an EFI System partition (either
MBR type 0xef or GPT type GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B),
format it as FAT12 or FAT16, and to put efi32/efi/syslinux.efi and
efi64/efi/syslinux.efi in there, naming them /EFI/BOOT/BOOTIA32.EFI and
/EFI/BOOT/BOOTX64.EFI, respectively. (On Microsoft it's "\" rather
than "/",
of course.)
Then put ldlinux.e32 and ldlinux.e64 into /EFI/BOOT of the partition.
I'd start with a readily installed BIOS-capable SYSLINUX image and use a
partition editor to create an 0xef MBR partition. MBR partition table
has the advantage that it does not tell the full disk size. So one image
fits all disks if they are large enough.

The rest seems to be a matter of customization needs. For example the
EFI partition content of Knoppix 8 (seen by GNU/Linux find(1)) is this:

  ./efi
  ./efi/boot
  ./efi/boot/BOOTX64.efi
  ./efi/boot/hashtool.efi
  ./efi/boot/keytool.efi
  ./efi/boot/loader.efi
  ./efi/boot/BOOTIA32.efi
  ./efi/boot/ldlinux.e32
  ./efi/boot/ldlinux.e64
  ./boot
  ./boot/syslinux
  ./boot/syslinux/linux
  ./boot/syslinux/linux64
  ./boot/syslinux/minirt.gz
  ./boot/syslinux/syslnx32.cfg
  ./boot/syslinux/syslnx64.cfg
  ./boot/syslinux/f2
  ./boot/syslinux/f3
  ./boot/syslinux/bootefi.msg
  ./boot/syslinux/german.kbd
  ./NvVars

I assume that "linux", "linux64" and "minirt.gz"
belong to a bootable Linux.
Why Klaus Knopper put it there is not clear to me.


Have a nice day :)

Thomas