1

I have studied that the during booting process, in the first stage, the boot loader in the MBR of a boot device looks into the partition table to find the boot sector of the active partitions and once it find the active partition then it searches for the second stage boot loader (eg: GRUB) and then loads in to the RAM. And that the second stage boot loader resides under /boot directory.

Q1) What if a system has 2 different Operating Systems? Will the display menu to select one of these operating systems gets displayed when the first stage boot loader looks for the active partitions?

Q2) If the 2 Operating Systems on the system are 2 different Linux distributions, then if both the distributions will have the same boot loader under their /boot directory, at what stage does these operating system menu appears for the user selection first stage or second stage?

1
  • Sounds like you've gotten part way through a "how GRUB works" article... just search for that & pick a few
    – Xen2050
    Commented Dec 21, 2017 at 4:17

2 Answers 2

2

No, the active partition is a DOS/Windows thing - it is the "bootable" flag. Many/most BIOSes will look for it though, but on non-x86 hardware it may not exist or care. https://en.wikipedia.org/wiki/Boot_flag

Once the bootloader has been found by the BIOS (or equivalent) - either by searching for the flag, looking in a default location, etc - then the bootloader's config will determine what operating system(s) get booted, or display a menu, etc.

How that happens is bootloader dependent - Back in the "old days" to dual boot Windows NT 4 and Linux we'd write lilo to the /partition, then strip off the first 512 bytes using dd into a file and put that where the Windows bootloader (ntldr) could see it, then make an entry in the C:\boot.ini file referencing it and changing the default boot option to Linux. Of course, each new kernel upgrade required re-writing lilo and re-stripping off those 512 bytes into a file...

1
  • The BIOS may look for an active partition, but, as the Wikipedia article you linked to says, only for deciding if the device should be considered for booting. After selecting which device (disk) to boot from, the BIOS loads the Master Boot Record (the first 512 bytes on the disk) into memory and starts executing the code loaded from the MBR. The BIOS hands over control to the boot sector code: the BIOS does not play any role in booting after this point, other than provide services. By convention, the boot code looks for the active partition to know which partition to boot from. Commented Dec 21, 2017 at 9:16
0

Most machines bought in the past year or two will default to using UEFI to boot the system, the advantage is secureboot, better ways for the OS to interact with the firmware, remote attestation, better handling of HD encryption, and a few other things.

UEFI firmware can pick what to boot in a few ways.

In the most compatible mode the firmware will look on the drive for a GUID partition with the partition type UUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B. (type ef00 in fdisk). This partition is formatted as FAT32 (I'm not sure if this is a strict requirement in the standard but I'm not aware of any real firmwares that will boot anything else, coreboot might though). On this partition the firmware will run /BOOT/EFI/BOOTX64.efi (for x64). This is the bootloader and can do whatever it wants. In fact the linux kernel is an EFI executable and when run it'll boot linux!

The other way is by reading a boot entry from EFI NVRAM. This is how most bootloaders (like the windows loader or grub-efi). This will add an entry to a firmware specific boot menu (usually accessed by something like F12 on boot) and that entry will point to a specific executable on the efi system partition. This way even if somebody clobbers BOOTx64.efi you can still easily boot your system. This method can be quite buggy on some machines. For example the NVRAM is supposed to run some garbage collection to reclaim space after a variable is deleted, but some older firmwares don't and will simply brick if you write too many variables. My own Lenovo X220's firmware won't boot from NVRAM entries at all, and can only load bootx64.efi. Any machine manufactured in the last 4ish years should be fine though.

Most linux distros will install grub (or whatever bootloader they use) in some directory like /fedora/... on the ESP (efi system partition), so you can select whatever copy you like from the EFI boot menu. If you have os-prober installed for a given linux then it's version of grub will probably be able to find windows' bootloader and run that for you from the grub menu.

One quick way to tell if you're booting with EFI is to just boot windows 10 and see if the logo that shows up is the windows logo or the logo of your machine's manufacturer. If it's not the windows logo you're in EFI mode.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .