[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: UEFI/"BIOS" booting


Stefan Monnier wrote:
> > the behavior of the firmware
> > and OS when faced with a disk that has both a GPT and an MBR partitions
> > is largely unspecified and will vary depending on your system).

David Wright wrote:
> I've yet to see a GPT disk that didn't have a protective MBR.
> I thought that's the reason why GPT starts at block 1 and not
> block 0: an MBR was designed into GPT from the start (no pun intended).

Indeed. The byte format of GPT is specified in UEFI. The Protective MBR is
the magic number of GPT. This implies that one cannot have a valid GPT and
MBR partitions with payload on the same disk.

But the code area of the Protective MBR can well be used to boot via BIOS.
EFI explicitely specifies that these bytes shall be ignored by EFI.
And as said previously, BIOS does not expect any partitions. Such expectation
could be in the MBR code, though. Most probably such code won't work with
GPT because of no bootable/active MBR partition.

Quotes from UEFI 2.4:

  5 GUID Partition Table (GPT) Disk Layout

  5.2 LBA 0 Format
  LBA 0 (i.e. the first logical block) of the hard disk contains either
  • a legacy Master Boot Record (MBR) (see Section 5.2.1)
  • or a protective MBR (see Section 5.2.2 [actually 5.2.3]).

  5.2.1 Legacy Master Boot Record (MBR)
  A legacy MBR may be located at LBA 0 (i.e. the first logical block) of
  the disk if it is not using the GPT disk layout (i.e., if it is using
  the MBR disk layout).

  5.2.2 OS Types
  Unique types [of MBR partitions] defined by this specification (other
  values are not defined by this specification):
  • 0xEF (i.e., UEFI System Partition) defines a UEFI system partition.
  • 0xEE (i.e., GPT Protective) is used by a protective MBR (see 5.2.2)
    to define a fake partition covering the entire disk.

  5.2.3 Protective MBR
  A Protective MBR may be located at LBA 0 (i.e. the first logical block)
  of the disk if it is using the GPT disk layout. The Protective MBR
  precedes the GUID Partition Table Header to maintain compatibility with
  existing tools that do not understand GPT partition structures.

  Table 15. Protective MBR
  Mnemonic             | Byte   | Byte   | Content
                       | Offset | Length |
  Boot Code            | 0      | 440    | Unused by UEFI systems.
  Unique MBR Signature | 440    | 4      | Unused. Set to zero.
  Unknown              | 444    | 2      | Unused. Set to zero.
  Partition Record     | 446    | 16*4   | [partition table]
  Signature            | 510    | 2      | Set to 0xAA55 [...]

The MBR partition table is described in table 15 as
  Array of four MBR partition records. Contains:
  • one partition record as defined Table 16; and
  • three partition records each set to zero.

Table 16 then states

  Protective MBR Partition Record protecting the entire disk
  Mnemonic     |Byte  |Byte  | Description
  BootIndicator| 0    | 1    | Set to 0x00 to indicate a non-bootable
               |      |      | partition. [...]
  StartingCHS  | 1    | 3    | Set to 0x000200 [...]
  OSType       | 4    | 1    | Set to 0xEE (i.e., GPT Protective)
  EndingCHS    | 5    | 3    | Set to the CHS address of the last logical
               |      |      | block on the disk. Set to 0xFFFFFF if it is
               |      |      | not possible to represent the value in this
               |      |      | field.
  StartingLBA  | 8    | 4    | Set to 0x00000001 (i.e., the LBA of the GPT
               |      |      | Partition Header).
  SizeInLBA    | 12   | 4    | Set to the size of the disk minus one. Set to
               |      |      | 0xFFFFFFFF if the size of the disk is too
               |      |      | large to be represented in this field.


Have a nice day :)


Reply to: