Introduction
In the world of technology, continuous evolution is, if not a rule, at least a fact. Two standards that have long challenged this claim are BIOS and MBR.
New standards have emerged and are now consolidated, namely UEFI and GPT. In some cases, UEFI is installed together with the BIOS and in other cases, it is completely independent. Learn a little more about the difference between the standards, their advantages and disadvantages.
What are BIOS and MBR and how do they work?
The BIOS is a firmware that resides on a chip on the motherboard and runs as soon as the computer is turned on. Its job is to communicate with the hardware and check that it is available and working correctly.
The MBR is a small sector located at the beginning of a storage device that contains information about its partitions, indicating where they begin and end, in addition to containing the operating system's boot code (bootloader).
The BIOS calls for execution the boot code that is in the first sector of the storage device defined with the highest priority in its settings. If the device is a CD/DVD, the BIOS uses the El-Torito specification, which is a standard for booting from optical media. If the device is another type of storage, such as a HDD, SSD or USB flash drive, the BIOS reads the code present in the MBR.
The BIOS does not recognize the partition table or the file system, it initializes the hardware and transfers control to the bootloader indicated in the MBR, which is responsible for managing these processes. Examples of Bootloaders include BOOTMGR (Windows), GRUB, LILO and Syslinux.
What are UEFI and GPT and how do they work?
UEFI is a specification designed by a forum composed of organizations and large companies such as Intel, AMD, Microsoft and HP, created with the objective of standardizing functionalities in a new firmware, eliminating the limitations of the BIOS.
GPT is a disk partitioning scheme used on systems with UEFI firmware that is more modern and flexible than MBR, allowing a much larger number of partitions and disk sizes.
UEFI introduces a different way of loading the operating system compared to the traditional method where the BIOS calls the bootloader by reading the MBR. UEFI is able to read the partition tables and understand the file system used, and supports both MBR and GPT.
No boot code is loaded into the MBR, whether it exists or not. UEFI uses a special partition in the partition table called the EFI System Partition (ESP). The ESP is formatted with the FAT file system and contains EFI applications, including boot loaders for operating systems and utility programs (e.g., RAM test).
To boot the operating system using UEFI, you need to store the file responsible for this function in the path /EFI/boot/bootx64.efi inside the EFI reserved partition. On some UEFI systems this may be the only method, but it is usually possible to access the boot file by browsing the folders inside the special partition.
Unlike BIOS, loading multiple operating systems (multiboot) can be done directly through UEFI. Each system can store its boot files within its EFI partition, and for UEFI it is simply a matter of loading one file for each operating system.
UEFI boot process
Computer is turned on
UEFI firmware is loaded from NVRAM and takes control of the boot process. UEFI can operate in both 32-bit and 64-bit, allowing for broader and more efficient access to hardware resources from the start.
UEFI initializes the hardware
UEFI initiates and monitors POST to ensure that each hardware component performs a self-test of its functionality. Examples of these components include the CPU, GPU, RAM, peripherals, storage devices, USB interfaces, batteries, and fans.
UEFI reads and loads the bootloader
UEFI firmware has a built-in boot manager that is responsible for loading applications located on the EFI System Partition (ESP) of a storage device. UEFI loads the EFI application responsible for booting the operating system (bootloader) into memory and transfers control to it.
Bootloader loads the kernel
The bootloader, now in control, loads the operating system kernel into memory, passing configuration parameters and hardware information to it, making the boot process more efficient.
After being loaded, the kernel configures the system hardware by loading drivers and starts the software environment, enabling system services.
Operating system and user space
Only then does the operating system transfer control to user space, allowing high-level applications and programs to load, thus completing the boot process.
MBR vs GPT
MBR
Using MBR, you can create only 4 primary partitions or 3 primary partitions and 1 extended partition. The extended partition allows you to create a larger number of logical partitions within it. If there is any remaining disk space that is not allocated to the extended partition, it will be inaccessible.
Within the extended partition, the metadata for logical partitions is stored in a linked list structure. If a link in this structure becomes corrupted, the operating system may have difficulty locating and accessing the logical partition information, potentially resulting in data loss.
The MBR uses only 1 byte to identify the type of a partition. With such a limited number (256, to be exact), there is a risk that different operating systems or partition software will assign the same code to different partition types. This can lead to conflicts when trying to identify or access a partition.
Another important point is that partition sector information is stored using a 32-bit LBA value. This LBA size, together with a 512-byte sector (the most commonly used), limits the disk addressability to approximately 2.2 TB. Any space beyond the 2.2 TB disk cannot be defined in a partition.
GPT
It uses unique identifiers (GUIDs) for each partition, avoiding conflicts and allowing the creation of a much larger number of partitions. This eliminates the need for extended or logical partitions and provides greater flexibility. The maximum number of partitions is determined by the space allocated to the partition table, which initially supports up to 128 entries. Tools such as gdisk allow you to adjust this limit, expanding the possibilities for configuring the disk.
Partition sector information is stored using a 64-bit LBA value, theoretically allowing addressing of disks up to 8 ZiB in size. Practical implementations may be limited by other factors, including sector size, operating system, file format, and hardware.
GPT has redundancy and integrity checking mechanisms that allow it to detect errors and corruption in partition data. These mechanisms include:
- Storing multiple copies of the header and partition table in different sectors of the disk, ensuring redundancy.
- The use of a cyclic redundancy check (CRC) value, which is calculated for each data block. Any change in the content results in a different checksum, allowing immediate error detection.
These mechanisms significantly increase the chances of recovery in the event of a failure and are fundamental to the integrity and reliability of data stored on disks that use GPT, especially in critical environments where data loss can have serious consequences.
Final Thoughts
The combination of UEFI bootloaders with GPT partitioned disks brings many advantages over its BIOS + MBR counterpart, such as better performance, greater flexibility, scalability and reliability, and should be preferred whenever available on a system with both options.
It allows, for example, the use of NVMe SSD disks more efficiently and the installation of multiple operating systems on the same disk more efficiently and securely.
The only caveat would be the presence of specific restrictions, such as limited compatibility of older systems or software with UEFI + GPT.
Referências
An old and now deactivated article from this website served as a starting point for the preparation of this text. Artificial intelligence was used to correct grammatical and semantic errors, in addition to optimizing the textual structure and vocabulary.