Tuesday, December 27, 2011

Master boot record

A master boot record (MBR) is a type of boot sector popularized by the IBM Personal Computer.It consists of a sequence of 512 bytes located at the first sector of a data storage device such as a hard disk. MBRs are usually placed on storage devices intended for use with IBM PC-compatible systems.

The MBR may be used for one or more of the following:

  • Holding a partition table, which describes the partitions of a storage device. In this context the boot sector may also be called a partition sector.
  • Bootstrapping an operating system. The BIOS built into a PC-compatible computer loads the MBR from the storage device and passes execution to machine code instructions at the beginning of the MBR.
  • Uniquely identifying individual disk media, with a 32-bit disk signature, even though it may never be used by the operating system.
Structure of a master boot record
AddressDescriptionSize in bytes
HexOctDec
000000000code area440
(max. 446)
01B80670440disk signature (optional)4
01BC0674444Usually nulls; 0x00002
01BE0676446Table of primary partitions
(Four 16-byte entries, IBM partition table scheme)
64
01FE077651055hMBR signature2
01FF0777511AAh
MBR, total size: 446 + 64 + 2 =512




Master Boot Record (MBR) / track 0

Master Boot Record (MBR):
The Master Boot Record (MBR) on x86-computers is the first sector of the hard disk. The MBR occupies exactly one sector (512 bytes). After starting the computer the BIOS automatically loads the first sector of the boot drive (C: or A:) and starts the code found on this sector. When the boot order is set to "C: , A:", then the BIOS tries to load the MBR from the first hard disk. When booting from A: comes first, then the BIOS tries to load the first sector of a diskette. When the sector has been read successfully (from C: or A:) it is executed. When the sector could not be read (e.g. booting from A: without diskette in drive A:) the BIOS tries to boot from the next boot drive.

On diskettes there is no MBR. Rather the first sector of the diskette contains the boot sector if the diskette is bootable, or a small program which asks the user to remove the diskette and press any key.
The MBR is a partition sector. All partition sectors have the same format (see format of partition sector), which is independent of the operating system. The MBR also contains a small boot loader program and the partition table. The partition table can contain up to four entries. Each entry describes a partition. The boot loader of the standard MBR searches in the partition table of the first hard disk for a primary partition marked as active. If such a partition is found, the boot sector of this partition is loaded and started. The boot sector finally loads the corresponding operating system.
Track 0:
The term "track" denotes a set of sectors all having the same head number and cylinder number. The "track 0" consists of all sectors with head and cylinder number 0. The first sector in the track 0 is the MBR. Since the sector number is restricted to the range 1 to 63, the track 0 contains at most 63 sectors. Usually the track 0 is empty (except for the MBR), hence this space can be used store small programs. This has the advantage that no additional partition must be created to store these data and furthermore there is no dependency on the file systems of existing partitions. The problem is that there is no indicator whether the track 0 contains some data or not. Therefore it could happen that other programs unintentionally overwrite the data stored in the track 0.