Limine BIOS chainloading enhancements
A couple of days ago, was working on what was planned to become
Limine Installer version 1.2, when hit a problem with BIOS
chainloading. Here is an overview of the situation so far, leading
up to a solution for the problem...
Introducing MBR_ID
Github member mintsuki has been very helpful, implementing
enhancements when I have reported issues. When I first got
involved with Limine, drive chainloading on a BIOS-firmware
computer was this:
Chainload protocol on BIOS:
DRIVE - The 1-based drive to chainload,
if omitted, assume boot drive.
PARTITION - The 1-based partition to
chainload, if omitted, or set to 0, chainload drive (MBR).
A problem with DRIVE number is that it may change. I raised this as an issue, and mintsuki introduced MBR_ID:
DRIVE - The 1-based drive to chainload, if
omitted, assume boot drive.
PARTITION - The 1-based partition to
chainload, if omitted, or set to 0, chainload drive (MBR).
MBR_ID - Optional. If passed, use an MBR
ID (32-bit hex value) to identify the drive containing the
volume to chainload.
In a MBR drive, you can obtain that 32-bit number like this:
# lsblk --pairs -o PTUUID,PTTYPE --nodeps /dev/sdc
PTUUID="c5e0f2d2" PTTYPE="dos"
PTUUID is a unique number identifying that drive.
VBR and PARTITION number
Good, but how is that PARTITION parameter used? We need to know
about the Volume Boot Record (VBR), also known as the Partition
Boot Record (PBR), see explanations here:
https://whereismydata.wordpress.com/2008/08/23/file-systems-mbr-and-volume-boot-record-basic/
http://glennastory.net/boot/pbr.html
This topic of the VBR arose because I couldn't see how to chainload Windows XP or 7, as they require executing binary files 'ntldr' or 'bootmgr', respectively.
Note, if the BIOS computer has been upgraded to Windows 10, that will also require executing 'bootmgr'. Windows 10+ on UEFI computers is a different situation, requiring launching a EFI file, that Limine can do.
Limine does not have to execute those binaries directly, it is
done via the VBR. If 'ntldr' or 'bootmgr' is found in a vfat
partition, say partition 1, then Limine Installer will create an
entry, say:
:Windows XP
COMMENT=Windows bootup
PROTOCOL=chainload
MBR_ID=c5e0f2d2
PARTITION=1
A likely scenario is that the computer has one drive, with
Windows XP or 7 (or 10), and you have installed Limine to the MBR,
thus supplanting the previous Windows bootup. So, this
chainloading brings back Windows as an entry in the Limine menu.
Introducing GPT_UUID
Now, the problem mentioned in first paragraph of this blog
post...
On a legacy-BIOS computer, the drive most likely has a MBR;
however, not necessarily, it may have a GPT (GUUID Partition
Table) -- which supports drives greater than 2TB, as well as other
benefits. I raised an issue about this:
https://github.com/limine-bootloader/limine/issues/201
mintsuki added an enhancement:
Chainload protocol on BIOS:
DRIVE - The 1-based drive to chainload,
if omitted, assume boot drive.
PARTITION - The 1-based partition to
chainload, if omitted, or set to 0, chainload drive (MBR).
MBR_ID - Optional. If passed, use an MBR
ID (32-bit hex value) to identify the drive containing the
volume to chainload. Overrides DRIVE, if present, but does not
override PARTITION.
GPT_UUID or GPT_GUID - Optional. If
passed, use the GPT GUID to identify the drive containing the
volume to chainload. Overrides DRIVE and MBR_ID, if present, but
does not override PARTITION.
That GPT_UUID is obtained with lsblk, same as before:
# lsblk --pairs -o PTUUID,PTTYPE --nodeps /dev/sda
PTUUID="91da59bf-979c-4d2c-b0da-a758cb1ba74f" PTTYPE="gpt"
It is very unlikely that a computer with Windows XP has a GPT
drive, but a Windows 7 PC might, or it could have been a
user-upgrade. So, the Limine entry, if 'bootmgr' binary is in
partition 1:
:Windows 7
COMMENT=Windows bootup
PROTOCOL=chainload
GPT_UUID=91da59bf-979c-4d2c-b0da-a758cb1ba74f
PARTITION=1
GPT_UUID has been introduced in Limine version 3.13, so I have
compiled that in OpenEmbedded. Uploaded here:
https://distro.ibiblio.org/easyos/amd64/packages/compat/oe/dunfell/limine-3.13-r9-nocona-64.tar.xz
Introducing chainload_next
To round off this post, mintsuki also implemented "chainload_next" protocol, after discussion here:
https://github.com/limine-bootloader/limine/issues/191
The documentation:
chainload_next protocol: This protocol does not specify any
locally assignable key on BIOS. Will boot the next bootable
drive found in the system, if there is one.
In a BIOS computer, with two drives, if you had installed the
second drive with Limine bootloader, if the first drive has
Windows, Grub, or whatever, you can chainload to it with this
protocol.
Tags: easy