Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 36 ยท Disk and File System Forensics

Disk Layout: MBR and GPT Partitions

Learn how disks are divided into sectors and partitions, how to read an MBR partition table byte by byte, how GPT differs, and what hidden or unallocated space means for investigators.

Before any file can be found, the examiner must know how the disk is organised. A drive is a long row of numbered sectors (usually 512 bytes, or 4,096 bytes on newer drives). A partition table at the start of the disk says which ranges of sectors belong to which partition, and each partition normally holds a file system. When a tool reports "no partitions found", or a partition seems to be missing, you can read the table yourself and see what is actually there.

Sectors, LBA and offsets

Sectors are addressed by Logical Block Address (LBA): sector 0 is the first, sector 1 the next, and so on. To get a byte offset, multiply by the sector size:

offset = LBA ร— sector size

For example, sector 2048 on a 512-byte-sector disk starts at byte offset 1,048,576 (1 MiB). Modern partitioning tools align the first partition at sector 2048, which leaves a gap of 2,047 sectors after the table. That gap is a place where data can hide, so examiners look at it.

flowchart LR
    S0["LBA 0<br/>MBR / boot code<br/>+ partition table"] --> G["Gap<br/>(sectors 1-2047)"]
    G --> P1["Partition 1<br/>from LBA 2048"]
    P1 --> P2["Partition 2"]
    P2 --> U["Unallocated<br/>space"]

The MBR (Master Boot Record)

The classic scheme stores everything in the first 512-byte sector:

Offset Size Content
0 446 bytes Boot code
446 4 ร— 16 bytes Four partition entries
510 2 bytes Signature 55 AA

Each 16-byte partition entry holds: boot flag (0x80 active), CHS start (3 bytes), partition type (1 byte, for example 0x07 NTFS/exFAT, 0x0B FAT32, 0x83 Linux, 0x05 extended), CHS end (3 bytes), starting LBA (4 bytes, little-endian) and number of sectors (4 bytes, little-endian). Because the LBA fields are 32 bits, MBR disks are limited to 2 TiB with 512-byte sectors, and four primary partitions (more with an extended partition holding logical drives).

Remember the byte-order rules from bits, bytes and hex. The program builds a made-up MBR and parses it the way a tool would.

Python Parse an MBR partition table

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The program prints byte offsets, which is exactly what you pass to a tool when you need to mount a single partition from a full-disk image.

GPT (GUID Partition Table)

Modern computers use GPT, part of UEFI. Its layout:

  • LBA 0: a protective MBR that shows one big partition of type 0xEE, so old tools do not think the disk is empty.
  • LBA 1: the GPT header, starting with the signature EFI PART, with the disk GUID, the location of the partition array, and a CRC32 check.
  • LBA 2 onward: the partition entry array, 128 entries of 128 bytes each by default. Each has a type GUID (EFI System Partition, Microsoft basic data, Linux filesystem...), a unique GUID, start and end LBA (64-bit), attributes and a UTF-16 name.
  • A backup header and array at the end of the disk.

GPT supports huge disks (zettabytes), 128 partitions and has redundancy. For examiners the backup copy is valuable: if the primary header is damaged or wiped, the backup at the end may let you rebuild the partition list. Mismatches between the two can themselves be a sign of tampering.

Python Detect a protective MBR and a GPT header

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Case C is an important finding: a protective MBR without a GPT header means something removed or damaged the header.

Hidden and unallocated space

When you list the partitions and their sector ranges, look at what is not covered:

  • Unallocated gaps between or after partitions can contain remains of deleted partitions, or hidden data.
  • The gap before the first partition (sectors 1 to 2047) can hold boot loaders, and malware sometimes hides there.
  • Deleted partitions may still have an intact file system whose start you can find by searching for file-system signatures.
  • Host Protected Areas (HPA) and Device Configuration Overlays (DCO) are drive features that hide the end of a disk from the operating system; a good imager compares the real capacity to the reported one.

The next stand-in finds the gaps in a partition list.

Python Find unallocated gaps between partitions

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Sample real tools (not run here): mmls image.dd from The Sleuth Kit prints a similar table, with the start, end, length and description of each slice; fdisk -l and gdisk -l show the table as the system sees it.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Where is the MBR partition table stored?

    Four 16-byte entries start at offset 446 of sector 0, followed by the 55 AA signature.
  2. 2. A partition starts at LBA 2048 with 512-byte sectors. What is its byte offset?

    2048 x 512 = 1,048,576 bytes (1 MiB).
  3. 3. What does a protective MBR with partition type 0xEE indicate?

    GPT disks carry a protective MBR so legacy tools do not treat the disk as unpartitioned.
  4. 4. Why is the backup GPT useful to examiners?

    GPT keeps a second copy at the end of the disk, which helps recover from damage and exposes tampering.

Summary

  • Disks are numbered sectors (LBA); byte offset is LBA times sector size.
  • The MBR holds four 16-byte partition entries at offset 446 and ends with 55 AA; LBA fields are little-endian.
  • GPT has a protective MBR, a header starting EFI PART, a partition array and a backup at the end.
  • Gaps, deleted partitions, HPA and DCO can hide data; always list what lies outside the partitions.
  • Offsets from the table tell you where each file system starts.

Next: File systems: FAT, NTFS and ext4