Master Boot Record in Windows OS
Introduction to MBR
Master Boot Record or MBR resides at the first sector of Hard Drive having code area, partition table and Boot Record Signature. It takes 512 bytes of size to maintain its structure in x86 & x64 bit architecture as shown in table 1. The 446 bytes are used for code area, 64 bytes are used for partition table and last 2 bytes are used for Boot Record Signature or magic number. Code area is responsible for checking entire hardware status, error messages displayed and locates bootloader and bootloader loads Operating System and any program. Partition table keeps record of each partition and allows maximum 4 partitions as shown in table 2. To perform more than 4 partition in Master Boot Record of Windows 7 we need to create 3 Primary Partitions and 1 Extended Partition. The Boot Record Signature has only two values 55 & AA to indicate ending of MBR and error detection. Boot Record Signature also called the Magic Number and it is written in 16 bit Hexadecimal as 0xAA55.
Table 1: Basic Structure of MBR
Table 2: Standard Primary Partition Table
MBR Working Procedure
When the computer’s power button is pressed BIOS (Basic Input Output System) performs POST (Power of Self-Test) operation to test all hardware components (RAM, HDD, CD-Drive, etc.) attached with Mother Board and to check whether all hardware are connected properly or not. If everything is connected properly then BIOS read MBR (Master Boot Record) on HDD (Hard Disk Drive), then MBR locates Bootloader, and loads whatever program (Windows 7 Operating System) it finds in the memory.
Role of Bootloader
The purpose of bootloader is to load the OS or any other program present on the HDD. GRUB (GRand Unified Bootloader) and LILO bootloader are generally used in Linux Operating Systems. In Windows, New Technology Loader (NTLDR) is used instead.
Master Partition Table
Each table entry for primary partition contains 16 bytes of size. The detailed description is shown in table 3. The first set of bytes with length of 1 byte contains the Boot Indicator whether this partition is active or not. Second, is Starting CHS (Cylinder, Head and Sector) values of partition and it takes 3 bytes of size. Third is Partition-type descriptor, which takes 1 byte of size and defines about the partition type like, NTFS, FAT & EXT, etc. Fourth is Ending CHS values keeps information of last CHS values of Partition and it also takes 3 bytes of size. Fifth is Starting sector contains information of starting sector of partition and it takes 4 bytes of size. The last offset represents the Partition size & contains information about size of partition, taking 4 bytes of size.
Table 3: Structure of Each 16 bytes Master Partition Table
Extended Partition in MBR
Extended Partition Table is the same as Master Partition Table and it is created in case of creation of more than 4 partition on a Hard Disk Drive. However, it is not necessary that extended partition be created after third partition creation. Extended partition can be created after one primary partition creation. It is necessary that there should be at least one primary partition on HDD to created extended partition. Partitions created in extended partitions are called logical drives. If any MBR contains EBR (Extended Boot Record) then it will always be examined. Technically, we can create any number of logical partitions but Operating System imposes its limit. Operating System applies one condition for creating extended boot partitions, that is, the Master Boot Record should always reside in the Primary Partition. Each logical drives are connected in a link of chain and OS reads every logical drive from the first logical drive to last logical drive. As we can see in fig 1 all logical drives are connected as a link or chain format. As shown in this figure the first partition is system reserved having size of 100 MB, and drive contains letter “C” is primary partition containing Master Boot Record and OS. In addition, the other partition with drive letter “D”, “E”, “F” and a free space drive are logical drives or an Extended Partition. The last drive partition shown in figure having black color is an unallocated partition.
Conclusion
In this blog, we have learnt about the internal structure of Master Boot Record in Windows 7 or any other Windows OS, its working, and the role of MBR in a computer to load OS, to manage Partitions & to create extended partitions. In addition, in next blog, we will learn about GUID Partition Table.