2

I was studying for my Linux+ exam and while taking notes I was attempting to explain the different stages of the grub bootloader to myself in my notes and I got hung up on a specific fact. To my understanding on hard drive with a mbr partition table the first 512 bytes (inner disk) store the partition table and the first stage of the bootloader (in my case grub). I wanted to say:

MBR style disks utilize the first 512 bytes of the drive for storing the partition table and the stage 1 bootloader. The stage 1 bootloader is the first of 2 parts of the bootloaders portion of the boot sequence. First the BIOS/UEFI looks within the first readable sector (512 bytes) of a mbr partitioned drive for the location of stage 1.5 of the bootloader. Stage 1 is essentially a pointer to tell BIOS/UEFI where to look for the second part of the bootloader. The second portion of the bootloader is stored on the first readable sector of the hard drive (usually several kib in size).

But I'm not able to confirm through research that it is correct to say the first stage or second stage is the first readable sector and I don't know if it would vary depending on which components perspective, the operating system or the firmware in the case that the operating system can't read the mbr.

To sum it up my questions are:

When people say "the first readable sector" are they talking from the operating system or firmware (BIOS/UEFI) perspective?

Does a difference exist between what the operating system can see of a mbr disk in comparison to what the computers fimware can see (UEFI/bios)?

For GPT Disks does the BIOS Boot partition only exist for backwards compatibility with BIOS?

Some of the graphics I was looking at to understand this topic:

MBR vs GPT

GPT WITH Bios boot partition

Credits: anchor.com.au

2
  • As always, I'd recommend happyassassin.net/2014/01/25/… as a good primer to how UEFI boot works. However, exams don't always match the real world, so it may be best to refer to your study materials and perhaps any official sources.
    – Bob
    Commented Feb 26, 2018 at 2:19
  • Just in case — I've updated my answer a bit. But at the end of the day, if you just care about the exam, you'd need an exam-specific answer ... which unfortunately I can't give you.
    – Bob
    Commented Feb 26, 2018 at 2:47

3 Answers 3

3

But I'm not able to confirm through research that it is correct to say the first stage or second stage is the first readable sector

The first sector is the first sector. As far as the legacy BIOS was concerned, it would only load the first sector of a drive into memory and pass control to whatever is in there (this "stage 1"). The BIOS itself is never aware of, nor does it care about, any "stage 1.5", "stage 2", etc. (which themselves are specific to GRUB — while other bootloaders typically apply similar methods, there is no rule requiring so). In fact, the BIOS doesn't even care about what "stage 1" is or does, as long as that sector can be read from the disk (though some firmware does look for a flag marking it as bootable).

When people say "the first readable sector" are they talking from the operating system or firmware (BIOS/UEFI) perspective?

Generally the same thing, though there are exceptions. "first readable sector" in itself doesn't tell you anything about whose perspective you are reading from. This would depend on context.

Does a difference exist between what the operating system can see of a mbr disk in comparison to what the computers fimware can see (UEFI/bios)?

Generally, no — assuming the OS has direct access to the physical disk. One exception is if virtualisation is involved.

For GPT Disks does the BIOS Boot partition only exist for backwards compatibility with BIOS?

Yes. Most GPT-based installations do not have a BIOS Boot Partition at all. Instead, they only have a EFI System Partition designed for boot from EFI-compatible firmware.


There are exceptions to the above. For example, the Host Protected Area can effectively hide part of the drive, however, the HPA is at the end of addressable space, not the beginning.

Other abstractions can come into play. For example, some types of RAID work at the operating system driver level, leaving the motherboard firmware and the operating system with different views of the drive. Other types will load an option ROM into the motherboard firmware, which can result in the firmware seeing a different "first sector" from what is exposed by the disk. Intel's "fake" RAID is an example of this.

And even what the disk exposes as the "first sector" (first block, with LBA) can be different from what is physically on the disk. We are long past the old days when the disk controller was separate from the physical disk, and these days we no longer know exactly how the disk's internal structure is laid out. If you really want to get technical, you could claim the "first readable sector" differs from what is internal to the drive, but this is largely pointless. Modern drives can also remap "unreadable" (damaged) sectors to spare areas internally — this is transparent to everything external.


Side note, first readable sector actually appears in a comment in the Linux 2.4 kernel source (removed in 2.6) for the Advanced Disc Filing System in acorn.c. Note that this file system (and the system it was introduced with) is from the 1980s and long disused. From Wikipedia:

Hard disc support in ADFS used the same format as L format floppies in terms of 256-byte blocks;[5] only the underlying arrangement of tracks and sectors differed depending on the actual drive used, but this was managed by the SCSI controller. It interfaced to a ST506/ST412-based Winchester unit via the BBC Micro's 1 MHz Bus, an Acorn-designed interface card (1 MHz Bus to SCSI adapter) and an off-the-shelf Adaptec SCSI controller (SCSI to ST-506 adapter).

1

The "BIOS Boot" partition is only needed by Grub on a PC that is booting in compatibility ("BIOS") mode from a disk with GPT partitioning. Grub needs the extra partition to store stage 1.5 of itself there. Grub has traditionally stored this data on sectors on the first disk "cylinder", before the start of the first partition. This is a bit of a dirty trick, because this area is kind of a "no man's land" and is not guaranteed to be free. And it is in fact not free if you are using a GPT partitioning, since the GPT partition table is stored in these disk blocks. Hence the need for a separate partition. When booting in UEFI mode, Grub is loaded from the EFI System Partition. (When booting in UEFI mode Grub is actually not needed at all, but that's a different story.)

0

You need to understand the order: OS > BIOS > FIRMWARE.

In this case the firmware is the drive's firmware.

The BIOS wants the LOGICAL first 512 bytes, because only the drive firmware's knows where it located on the magnetic surface (HDD) / which electric cell belong to it (SSD).

So everything logical until the final hardware, only the final hardware works with real physical addresses.

The request for first 512 bytest addressed to DRIVE, not depend on OS or BIOS.

When people say "the first readable sector" are they talking from the operating system or firmware (BIOS/UEFI) perspective?

They talking from the DRIVE perspective.

Does a difference exist between what the operating system can see of a mbr disk in comparison to what the computers fimware can see (UEFI/bios)?

Regardless BIOS type, everything starts at first sector, and its contents decide where to forward (don't limit to HDD, optical disc may have no boot record, but they have logical 0 sector)

For GPT Disks does the BIOS Boot partition only exist for backwards compatibility with BIOS?

No need to be boot partition (like on storage-only HDDs, or raidX volumes). On EFI systems, there's an EFI partition, on system drive.

5
  • I appreciate your response but that doesn't answer my questions.
    – Kyle
    Commented Feb 26, 2018 at 2:06
  • "When people say "the first readable sector" are they talking from the operating system or firmware (BIOS/UEFI) perspective?" Wrong question. BIOS is not firmware. First readable sector is the request for DRIVE's first sectors, not related to bios or OS. (and this is a logical request, because only drive knows where these sectors)
    – uDev
    Commented Feb 26, 2018 at 2:11
  • How can you say bios isn't firmware? Firmware is just software thats been written to hardware and that is exactly what bios is? And from all the reputable sources I've been reading the bios or uefi finds where to boot from the first readable sector of the mbr hard disk.. And when you say "so everything logical until the final hardware" I doubt anyone can actually understand what you mean when you say that. If you don't know an answer then don't submit a very vague and generalized statement about hard drive firmware and stay on topic. -1
    – Kyle
    Commented Feb 26, 2018 at 2:12
  • @uDev Modern drives have firmware, yes. But the motherboard also has firmware. Motherboard firmware on modern x86 systems implement the UEFI standard and often also the de-facto legacy PC BIOS standard, but that doesn't mean it's not firmware.
    – Bob
    Commented Feb 26, 2018 at 2:15
  • Everything we can call firmware which runs in own hardware area. So drive has firmware (not new, 20 years old HDDs also have firmware, without it could not manage the head etc, s.m.a.r.t. also managed by this). Motherboard also have a firmware, which part is the BIOS. EFI is a non-integrated firmware, mostly software (because not flashed to chip except Apple Macs).
    – uDev
    Commented Feb 26, 2018 at 2:22

You must log in to answer this question.

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