0

There seems to be conflicting information on this.

The Wikipedia entry for Master boot record (aka "boot sector") says:

"The MBR is not located in a partition; it is located at the first sector of the device (physical offset 0), preceding the first partition. (The boot sector present on a non-partitioned device or within an individual partition is called a volume boot record instead.)"

But the Wikipedia entry for Volume boot record says:

"On partitioned devices, it is the first sector of an individual partition on the device."

So, I'm uncertain if the boot sector (1) precedes the first partition or (2) is included in the first partition.

If it is included in the first partition, then clearly it is not a partition.
If it precedes the first partition, however, I am uncertain.

My understanding is that when GPT is used, we have the concepts of "BIOS Boot Partitions" and "EFI System Partitions".

Alex Ryan
  • 111

3 Answers3

2

In classical MBR mode a boot sector can be at the beginning of the disk or beginning of a partition. A boot sector is tiny, and is not a partition.

UEFI is entirely different and does not use boot sectors - rather files in an appropriately formatted and labeled partition are used.

davidgo
  • 73,366
2

The information is not conflicting, because there are two levels or stages of "boot sectors" on a regular, partitioned disk. In other words, the MBR and the VBR are not the same thing – one exists outside partitions, the other inside.

Boot process always starts at the MBR, which is the 0th sector of the whole disk. It lives outside of any partition; indeed the same sector is where the partition table itself is stored. But the MBR is tiny and cannot contain much code – its primary task is just to choose a partition and jump to that partition's sector 0, aka its VBR.

Now if you have an unpartitioned disk (e.g. floppy disks or some USB sticks) whose filesystem (the "volume") just starts straight at sector 0 of the whole disk, then the MBR and the VBR just happen to overlap. The BIOS still executes what's in sector 0 of the whole disk, but that "MBR" code doesn't need to jump off to another level, it just directly does what a VBR would do. But in the general case they are nevertheless two different things.


The above is the generic PC BIOS boot process. But it's not set in stone – the BIOS itself literally doesn't care about partitions or volumes, it only starts the disk's sector 0 and lets it care about the rest. Once the MBR code is started it can do whatever it wants.

This means that there are bootloaders which do not follow the VBR convention at all. The GRUB bootloader is the main example of a bootloader which does its own thing – its MBR code does not jump into a VBR, but instead into a separate disk area at a fixed position. The GPT "BIOS Boot Partition" is also a GRUB invention that isn't used by other bootloaders.


Finally, modern UEFI systems don't have boot sectors at all. They can use MBR-format disks but they completely ignore the actual boot code stored in either the MBR or the VBR. Instead an UEFI system always boots using actual files stored in the "EFI System Partition".

grawity
  • 501,077
1

Basically, for legacy MBR, there's two types of boot sectors, a "Master Boot Record" and a "Volume Boot Record."

A partition is a portion of a hard drive defined by a partition table.

In the MBR (not GPT) case, it's pretty simple. There's a couple bytes, one determines the partition type (add 128 to mean "bootable"), the other bytes say which sector the partition starts and what size it is.

Let's look at a real partition table, this is the output from fdisk -l /dev/sda on a Linux system of mine. This will provide the table in human-readable format. The information is partition, boot flag (* = boot), start sector, size, end sector (computed from start + size), and type (fdisk has a named list of types).

/dev/sda1  *      2048   999423   997376  487M fd Linux raid autodetect
/dev/sda2       999424 31277055 30277632 14.4G fd Linux raid autodetect

As you can see, the first partition does not start at sector 0. 2048 * 512 bytes per sector means the first 1 megabyte of this disk isn't owned by any partition.

This is common for various reasons, but the partition table and legacy MBR boot code only uses the 512 bytes in sector 0. The top 66 bytes of that is a 64-byte partition table and a 2-byte signature that tells legacy BIOS that a partition table lives there. Depending on the OS, other areas of the MBR may be used to mean other things.

Sectors 1-2047 can be used by bootloaders, disk utilities, etc.

The "volume boot record" is simply the first sector of each partition. So there are VBRs on sector 2048 and 999424 of this disk.

Windows MBR will read the partition table, find the first bootable partition, and run its VBR.

  • Can the first partition start at 0 and include the MBR?

Yes, but A) the operating system has to be expecting this, and B) this is a bad idea if you expect other operating systems to coexist on the hard drive. I would imagine most operating systems would refuse to boot or mount this type of partition but have never tried.

  • Can the first partition start at sector 1?

Yes, but because of "Advanced Format drives" that internally have sector sizes of 4096, you want that number divisible by 8, for various reasons that can impact performance.

  • Can the first partition start at sector 8?

Yes, but some things that depend on that first 1M being free won't work. Linux GRUB bootloader I think is one of them.

  • Can you have gaps in the partitions?

Sure. It will be space not touched by operating systems that obey the MBR.

  • Can you have overlapping partitions?

Yes, but it's obviously a bad idea. Not sure how OSes handle it. Some old OSes like DOS probably won't check and may crash or fail spectacularly. Others may refuse to mount the partitions.

  • Can you have partitions off the end of the physical disk?

See above.

LawrenceC
  • 75,182