What is Partition Table?
The partition table of the disk cuts it further into more logical disks. The reason for doing it here follows: Before Windows 95 and DOS, old versions do not support file systems larger than 2GB. Therefore, partitions are needed to break the barrier. Different partitions may carry different file systems such as FAT, HPFS, NTFS, etc. Even small partitions are there to use for specific purposes. For example, even some laptops have a “Hibernation Partition” to store the system’s state when it goes into hibernation. Some systems also have backup partitions.
The DOS uses drive letters A: and B: for floppy disk drives and assign letters C: to Z:, for the primary partitions on the first disk, then primary partitions on the second disk, and so on… then all logical partitions in the first disk, etc.
What is MBR?
MBR or master boot record is nothing but a boot sector at the beginning of the drive partition.
MBR stands for Master Boot Record. It is a concept enforced in personal computers in DOS 2.0 versions. Master Boot Record is the very first boot sector of the hard drives of personal computers, removable drives, and other fixed disks.
It is generally referred to as Boot Loader. It is the crucial area on the computer hard disk that guides the Operating System to the location of the boot block or bootable partition on the hard drive. The Master Boot Record stores all the information about the logical partitions, their file systems, how they are organized on the hard drive.
In addition, it contains the executable codes to function as a loader to assist the Operating System in BIOS-based computers. Generally, it passes the control over to the Boot Loader in the second stage or in conjunction with the Volume Boot Record of the partition handling.
It can store up to 2 TiB (232 × 512 bytes) of the data in the partitioned disk or medium. Unfortunately, most Master Boot Record Compliant OS can do severe data corruption when used outside of a narrowly controlled computer system environment. Due to this, Master Boot Record-based partitioning was superseded by the GPT partitioning scheme. Further, GPT can co-exist with Master Boot Record to provide backward compatibility in some older computer systems.
It is sometimes called a partition sector. It is the master partition table that includes the location of each partition of the hard disk. This table also contains the program or the executable code that could read the partition’s boot record to be booted into RAM. Master Boot Record is generally created when a drive is partitioned and doesn’t stay within the partition itself. Master Boot Record is located in the first sector of the disk. Their CHS address is Cylinder “0,” Head “0,” and Sector “1”.
The minor program or the executable code examines the partition table and identifies and recognizes the system partitioning. Then, while the BIOS checks the hardware, the bootstrapping reads the Master Boot Record from the Cylinder Head Sector memory and executes it.
The Master boot record finds the starting location of the disk or the partition. Then it loads the copy of its partition boot sector into the memory. In addition, it transfers the execution to the executable codes in the boot sector. The LBA (Logical Block Addressing) was introduced in 1996 to support hard drives larger than 8GB. But Microsoft implemented some modifications and enforced CHS Cylinder- Head- Sector access for its FAT16B and FAT32 Partitions used. As a result, MBR Boot Code/ MBR partition entries are limited to 32 bits, but the current size standard is 512 bytes.
The first 446 bytes of the Master Boot Record is the Primary boot loader that contains executable code. The following 64 bytes hold a partition table that describes the volumes. The last two bytes are called the magic number. If the value is equal to 0xAA55, then BIOS will assume it is a valid Master Boot Record; if not, the BIOS will flash an error message.
If a drive is greater than that can be represented by 32 bits, it may need additional bits. That is, if your storage is more than 2TB capacity, then it needs additional bits proportional to the storage capacity. Therefore 2.199 TB capacity can be addressed using 512-byte sectors. Thus more than 2.2 TB capacities cannot be partitioned using the MBR partitioning scheme. Therefore, the Master Boot Record consists of 512 or more bytes located in the hard drive’s first sector.
It contains at least one of the following or more: a partition table, bootstrap code, volume boot record or chain loader, 32-bit disk timestamp, and 32-bit disk signature. The Master Boot Record partitioning can contain a maximum of four primary partitions or, alternatively, three primary partitions and one extended partition. In the partition table, the partition type can be found by a single byte code in the table entry. The BootLoader that checks the partition table decides whether the partition contains a file system that can be accessed for reading/ writing data.
The primary partition is called a system partition, which must be the first partition. Windows can be located on any of the partitions in modern systems, but the boot files, such as io.sys, bootmgr, ntldr, etc., must reside on the primary partition. Sometimes BIOS may also decide on which partition the Operating system must-have.
A hard drive may contain only one extended partition, but the extended partition can be subdivided into multiple logical partitions.
Bootstrapping of a system generally refers to a self-starting process that is supposed to continue or function without any external input source.
Booting is the process of starting computer software. It involves a chain of stages; in each stage, a smaller program loads, and then it executes the more extensive or more complicated program of the further stage. In simple terms, booting is a chain of events that begins with the execution of hardware-based procedures and is then handed off to the firmware software, which is loaded into the main memory. Therefore the booting involves processes such as doing power-on self-tests called pre-boot sequences such as Loading configuration file-setting, loading BIOS, Operating system, and utility software.
The BIOS reads the MBR from the drive into physical memory, and then it guides the processor to start the boot code. The BIOS runs in real mode (real address mode- real locations in memory); therefore, the processor is in real mode when the MBR is about to execute, which means Master Boot Record is expected to contain real-mode machine language or code. The BIOS bootstrap routine load and run only one sector from the partition table; therefore, it simplifies the MBR program. It usually has a small program that loads the volume boot sector or volume boot record of the targeted partition.
Once it is loaded, the control is transferred to this code; the code is responsible for loading the operating system. This entire process is called chain loading. Chain loading is similar to the use of overlays, but in chain loading, it replaces the currently executing program as its whole. The chain loading passes control to the boot sector from the boot manager. Next, the target boot sector is loaded in from the disk. Finally, the boot sector checks the partition table, finds the right one with the active flag, loads, and runs the VBR of the active partition.
Some boot managers come with alternative boot code implementations, which operate in different ways. Few boot managers load additional codes from the disc’s first track and execute it. Meantime the MBR program interacts with the user and decides which partition on which drive should boot so that it will transfer the control of the Master Boot Record of that particular drive. The MBR code also contains the list of disk location where the files and file system resides. It is just a reminder of the boot manager code to load and execute. The non-BIOS firmware and EFI’s Master Boot Record are not used as part of the system bootstrap.
MBR Disk Partitioning:
Earlier the DOS introduced the FDISK (FDISK utility is the command-line utility that provides disk partitioning functions, preparatory to defining the file systems) utility to set up and organize the MBR partitions. When your storage is partitioned according to the FDISK scheme, the Master Boot Record contains the partition table detailing the location, size, and a few more attributes of the linear regions of the referred partition. Sometimes the partitions themselves may have data of more complex partitioning schemes. For example, they may contain meta descriptions, Logical Disc Manager, BSD disk labels, EBRs.
We already discussed MBR is not located within the partitions. It is located in the first sector preceding the first partition. The boot sector located in the non-partitioned drive or in the individual partition is called Volume Boot Record. While the computer is running the Dynamic Drive Overlay or the boot manager, move the partition table to some other physical location on the device. For example, Ontrack Disk Manager often placed the copy of the Master Boot Record in the second sector and hid itself from the other applications.
MBR Sector Layout:
By convention, there are four primary partition table entries in the MBR partition table scheme. But some operating systems extend this to five advanced active partition tables. Even some of them have eight as well as sixteen entries.
Structure of a Classical Generic MBR
|0x0000 (0)||Bootstrap Code Area||446|
|0x01BE (446)||Partition Entry No1||16|
|0x01CE (462)||Partition Entry No2||16|
|0x01DE (478)||Partition Entry No3||16|
|0x01EE (494)||Partition Entry No4||16|
Structure of a modern standard MBR
|0x0000 (0)||Bootstrap Code Area- Part 1||218|
|0x00DA (218)||0x0000||Disk Time Stamp||2|
|0x00DC (220)||Original Physical Drive||1|
|0x00DD (221)||Seconds 0-59||1|
|0x00DE (222)||Minutes 0-59||1|
|0x00DF (223)||Hours 0-23||1|
|0x00E0 (224)||Bootstrap Code Area- Part 2||216/222|
|0x01B8 (440)||32-bit disk signature||Disk signature||4|
|0x01BC (444)||0x0000 (0x5A5A if copy-protected)||2|
|0x01BE (446)||Partition Entry No.1||Partition Table
|0x01CE (462)||Partition Entry No.2||16|
|0x01DE (478)||Partition Entry No.3||16|
|0x01EE (494)||Partition Entry No.4||16|
|0x01FE (510)||0x55||Boot Signature||2|
Partition Table Entries:
In good old hard disk partition technology, the partition table subdivides storage using CHS addressing, using units of cylinders, heads, and sectors. But it is not employed in the latest solid-state drives. In CHS addressing, the sector indices always start with sector one and not with sector 0 by convention. Due to error, the number of heads is limited to 255 and not 256.
Due to the limitation of CHS addressing, people have started using LBA (Logical Block Addressing). The length of the partition and the partition start address are sector values stored in the table entries as 32-bit quantities. Therefore, the entire sector size is 512 bytes.
The important hard-coded components are the Data flow management system, boot sectors, OS, DBMS, file system partitioning tool, software, backup, etc. In theory, the partition table can use 512 bytes sectors to allocate the disk. But in practice, only certain LBA 48 enabled OS can support this. Even when a disk has been partitioned with GPT, the Master Boot Record will still be there. Its only purpose is to notify the existence of GPT and prevent other programs from accidentally erasing the GPT.
Besides Bootstrap Code and the partition table, the master boot record may also contain a disk signature. It is a 32-bit value meant to identify the disk medium uniquely. It was first introduced in Windows NT 3.5 version. But now it is widely used by several other Operating Systems also. For example, Linux uses this fault tolerance signature to determine which disk the machine booted from. At the same time, Windows NT uses this HDD signature as an index to all the partitions on the disk. This disk signature is kept in windows registry keys to store the mapping between the disk partitions and Drive-letters. It may also be used in files of Windows NT boot.ini to describe the location of Operating System partitions. You can check the Registry entry herein:
The Windows OS started to store the disk signature in the Boot Configuration Data from Vista onwards. The entire boot process depends on the BCD itself. If there is a disk signature conflict, then the windows cannot be booted. Further, Windows usage is conflictive with the advanced active partition feature of PTS-DOS 7; if the boot code is located outside of the 8 GB of the disk, then the LBA addressing will be used.
In the sector editor or disk editor, the MBR signature will appear as the sequence of 55 AA. The bootstrap sequence of BIOS loads the first valid MBR in the physical memory at the addresses 0x0000:0x7C00. This magic number 0x7C00 belongs to the BIOS specification. And it is the memory address at which BIOS loads Master Boot Record. Once executed, the last instruction; jumps to that address for the direct execution of the beginning of the Master Boot Record copy. Once booted, the BIOS verifies and validates the signature 0x01FE, then only it will proceed to verify the valid partitions tables and report the disk capacity.
The BIOS treats the floppy drive and the fixed disk as the same. The BIOS reads the very first physical sector of the media at the addresses 0x7C00 and checks the last two bytes of the previously loaded sector; if the signature is found correct and validated, it transfers the control to the first byte of the sector with further Jump instructions.
Therefore the Master Boot Record loading volume boot record into RAM is precisely similar to the same floppy disk VBR loading the object code of the operating system loader into the RAM. In Both cases, BIOS proceeds to the Chain Loading of an OS. The last 66 bytes of the 512 byte Master Boot Record are reserved for table and other related information. The boot sector program must be small enough to fit within 446 bytes.
MBR vs VBR
First, the MBR code examines the partition table, selects the correct partition table, and loads the program to perform the boot process’s further stage. During this boot process BIOS interrupt calls OS and other system applications to invoke the facility of the Basic Input/ Output System. Then the Bootstrap code loads and runs the VBR that is available at the beginning of the active partition. The volume boot record (VBR) will fit with 512 bytes. But it is better than MBR code to load additional sectors to accommodate boot loaders longer than one sector.
The BIOS considers the VBR and MBR precisely alike. The status field in the partition table mentions the active partition. The Master Boot Record will allow only one partition to be marked active and use it for sanity checks to finalize the partition table. It will display an error message if two or more partitions are active. Some systems use the first marked partition in the row in this situation. Modern Master Boot Record accepts 7 bits active flag to pass on the original DL Value inserted by the BIOS instead of using the entries in the partition table itself.
We already discussed MBR is loaded at memory location 0x0000:0x7C00 with the register entry CS: IP = 0x0000:0x7C00. It passing execution to it by jumping to 0x0000:0x7C00 in the CPU real mode.