3 ms·
I also recommend the Starman for good documentation over the decades. Basically you're supposed to know BIOS/MBR booting quite well in order to make the best p
by fuzzfactor 4y ago
I also recommend the Starman for good documentation over the decades.
Basically you're supposed to know BIOS/MBR booting quite well in order to make the best progress on UEFI/GPT.
Originally upon powerup the BIOS would run from ROM and then boot control to a program known as the Master Boot Record which would reside on the first 440 bytes of sector 0 of the HDD. The partition table took up the final bytes of sector 0. The MBR checked which of the 4 possible primary partitions was flagged as active, and then booted control to the Volume Boot Record (Boot Sector) residing at the first sector of that particular partition which would then (usually, but specifically according to BOOT.INI on Windows [BCD today] or GRUB configs for Linux) load the OS contained within that partition. Usually by reading files from the filesystem beyond that point, but capable of being chained directly to other executable sectors.
Starman can be a very good resource on underlying structures:
https://thestarman.pcministry.com/asm/mbr/ https://thestarman.pcministry.com/asm/mbr/
He's got lots more pages like this, and references too.
Now, straight to modern UEFI:
The MBR code itself is best not there on sector 0, just an imitation partition table in the final few bytes still exists which is considered "protective" and keeps BIOS PC's from recognizing the HDD since they can not handle partitions layed out by the GPT regime.
Sector 1 designates GPT drive parameters, and sector 2 begins the defining data for each partition, which by default extends to sector 33 so you have room to define many more than 4 partitions, and any of them can be booted to from a single EFI folder on a hidden ESP partition, depending mainly on the config files in the EFI folder. There are backups of these defining sectors (not the EFI folder itself) in the final area of the HDD.
In the ESP partition which is often expected by MB UEFI to carry a specific ESP GUID (but often works just fine after changing to a "regular" GUID so you can unhide it for maintenance), the UEFI expects to find it formatted as FAT32, and there behold a recognizable EFI/BOOT folder containing the elusive BOOTX64.EFI file. That's the only thing normally found in the EFI/BOOT folder except for systems having bootability by the rare remaining 32-bit UEFI firmwares, then you might see BOOTIA32.EFI. Lots of times it will do just fine having an EFI folder on an NTFS partition too.
UEFI 64-bit firmware just runs whatever file is currently named BOOTX64.EFI in the BOOT folder. Or falls back to secondary alternatives if not present.
When you install an OS like Windows it adds an EFI/MICROSOFT folder, but each time you add a different version of Windows to a different partition, you do not add additional Microsoft folders to EFI, instead you add additional boot entries to the default boot menu already present in the Microsoft BCD file there. The OS installation procedure overwrites the existing BOOTX64.EFI file with one directing the boot process to continue from the Microsoft folder after that point, according to the NT6 boot menu you have in place at the time.
Installing Linux creates an EFI/ubuntu folder for example, containing most necessary GRUB elements, while overwriting BOOTX64.EFI to direct the boot process to the ubuntu folder and use the GRUB bootmenu accessible from there. Each distinct distro will add its own folder like EFI/debian/, EFI/fedora, with the most recently added claiming the most coveted BOOTX64.EFI prize.
Ideally, you install all the Windows versions you want into their designated NTFS volumes, which naturally builds up your NT6 bootmenu as you go. You will best do some BCDEDITing as you go just to keep the Descriptions in the bootmenu straight as to which entry goes to which Windows version on which partition.
Ideally again, your final Linux install will be a distro that automatically detects all other Linux installations residing on their EXT-formatted partitions, while also correctly detecting & adding a bootentry for Windows, so GRUB can take you to your already-established NT6 bootmenu when you want.
In the EFI/Microsoft folder you will find an os-specific file in EFI/Microsoft/BOOT named BOOTMGFW.EFI. Not to be confused with the basic EFI/BOOT/BOOTX64.EFI.
These are EFI executables, either one will boot the PC from UEFI directly if you drop down to the UEFI Shell preboot using your MainBoard tools. Navigate to fsx:EFI/Microsoft/BOOT and run bootmgfw.efi to boot Windows (even without an EFI/BOOT folder present), or navigate to the main EFI/BOOT folder and run the latest BOOTX64.EFI that your final OS install has overwritten for you accordingly. Where "fsx:" is the filesystem which contains the EFI folder as detected by the UEFI firmware, often fs0. You can even find grubx64.efi files for Linux.
Not only OS installs, but things like GRUB updates and BCDBOOT commands can overwrite BOOTX64.EFI.
Finally, once different OS's are properly installed in a traditional self-contained way on each of their own partitions, you should be able to craft any number of alternative EFI folders or contents such that any or all of the OS choices are presented to you on a bootmenu upon powerup, booting to your established choice of default (or fallback) in case of unattended powerup. GRUB can still boot Windows but Windows NT6 bootloader can no longer boot Linux when using GPT.
But you can even still make a boot floppy you can use to load OS's present on the HDD without having any boot files on the HDD at all.
UEFI can also sometimes do well when it finds a good recognizable EFI folder on an MBR-layout HDD.
- jaclaz 4y ago>The MBR checked which of the 4 possible primary partitions was flagged as active, and then booted control to the Volume Boot Record (Boot Sector) residing at the first sector of that particular partition which would then (usually, but specifically according to BOOT.INI on Windows [BCD today] or GRUB configs for Linux) load the OS contained within that partition. Usually by reading files from the filesystem beyond that point, but capable of being chained directly to other executable sectors. You forgot the Windows boot manager, on Windows NT the chain is: Up to XP: BIOS->MBR->PBR of active partition->NTLDR (+NTDETECT.COM)->BOOT.INI->Choices->OS Vista and later: BIOS->MBR->PBR of active partition->BOOTMGR->\boot\BCD->Choices->OS The MBR only passes control to the PBR and the PBR only loads the Windows boot manager, it is this latter that does all the actual OS loading and that reads BOOT.INI and \boot\BCD settings and user choices.
- fuzzfactor 4y agoGood to see your message jaclaz. You're another one like Starman who can fill in details like no-one else, in case people are not aware. Please kindly post a link to the message board where your most valuable information still can be found! What I'm seeing now is when Windows 8+ is installed to an MBR partition, and boots normally from a plain NT6 BOOT folder using BOOT\BCD in legacy CSM mode no differently than Vista (whether the boot folder is on a separate hidden volume or the same partition as Windows itself), the same Windows files on that partition can also boot using UEFI if available, from an alternative EFI\BOOT folder (plus accompanying EFI\Microsoft\BOOT\BCD) on the same or similar media. In the first case with BIOS it ends up running winload.exe, but under UEFI the firmware runs winload.efi instead, since both the "DOS" executable and the EFI executable are both present in the Windows\System32 folder, you have your choice here too.
- jaclaz 4y agoThanks for the comparison, though of course the Starman's site is a much better source than my scattered posts, mainly on: https://msfn.org/board/ https://msfn.org/board/ and: http://reboot.pro/ http://reboot.pro/ (on this latter under the nick of Wonko the Sane) About your Windows 8+ report, yes, what you describe is perfectly normal, what many people tend to forget is that UEFI does not necessarily means GPT, a UEFI can access "MBR style disks" just fine (the opposite, BIOS acccessing a GPT disk needs special provisions, so-called hybrid MBR's and "special" code in them). You evidenced however yet another aspect of more recent NT Windows booting, until XP NTLDR was both the boot manager and the OS loader, now BOOTMGR (and bootmgr.efi) is just the boot manager and it chainloads a separate OS loader, the WINLOAD.EXE (or winload.efi).