MBR vs GPT – Partition Table Formats Explained

By | May 20, 2023

In a previous post we already discussed about UEFI and BIOS and how the boot process work with each of them. Now in this post we shall take a look at the partition table formats, namely MBR and GPT.

They basically define data structure formats that hold partition information on the drive. Without the partition information in place, the system would not know where a partition ends and where does the next one begin.

Check the partition table scheme (MBR/GPT)

On Linux there are couple of commands to check that, however to make it easier, just run Gparted and select the drive of interest and it will show the partition table type on the left side "Device Information" column. For MBR it will show "msdos" and for GPT it will show gpt.

On Windows you can use the Gparted tool or Disk Manager application:

To view the partition scheme of your storage devices on linux, you can the "parted -l" command or the "lsblk" command. Here is the output of lsblk command on my Ubuntu desktop which has couple of external ssds and usb drives connected:

$ lsblk -e7 -o "NAME,PTTYPE,FSTYPE,SIZE,LABEL,PARTLABEL,PATH,PHY-SEC,VENDOR"
NAME   PTTYPE FSTYPE    SIZE LABEL              PARTLABEL PATH      PHY-SEC VENDOR
sda    dos            111.8G                              /dev/sda      512 ATA     
└─sda1 dos    ext4     95.4G                              /dev/sda1     512 
sdb    dos            111.8G                              /dev/sdb      512 ATA     
└─sdb1 dos    ext4     95.8G                              /dev/sdb1     512 
sdc    gpt            447.1G                              /dev/sdc      512 ATA     
└─sdc1 gpt    ext4      400G                              /dev/sdc1     512 
sdd    dos            465.8G                              /dev/sdd      512 Samsung 
└─sdd1 dos    ext4      420G                              /dev/sdd1     512 
sdf    dos             14.6G                              /dev/sdf      512 SanDisk 
└─sdf1 dos    vfat     14.6G UBUNTU 22_1                  /dev/sdf1     512 
sdg    gpt    iso9660  28.9G Ubuntu 22.10 amd64           /dev/sdg      512 hp      
├─sdg1 gpt    iso9660   3.8G Ubuntu 22.10 amd64 ISO9660   /dev/sdg1     512 
├─sdg2 gpt    vfat      4.2M ESP                Appended2 /dev/sdg2     512 
└─sdg3 gpt              300K                    Gap1      /dev/sdg3     512 
$

The PTTYPE column value when "dos" indicates MBR partition style, and when "gpt" indicates the GPT style partiton table.

MBR - The legacy partition scheme

MBR is the old partitioning scheme that has been used traditionally on most pc and laptops whether windows or linux based. It is being succeeded by the newer GPT that comes as a part of the UEFI parcel.

The mbr partition table supports a max of 4 primary partitions. The "extended" partition that we used to create in old days was just a special primary partition containing further child partitions call logical partitions.

1. 4 Primary
2. 3 Primary + 1 Extended Partition (with multiple Logical partitions)

MBR is limited in many ways, and the most important drawbacks are:

  • 1. The address length is only 32 bits. So MBR can access only upto 2^32 x 512 bytes = 2 TiB (2.2 TB ) of drive space.
  • 2. The boot-loader area can hold only about 446 bytes of data which makes it difficult to install feature-rich boot-loaders like grub in the mbr.
  • 3. Not possible to have more than 4 primary partitions. The workaround is to have 3 primary + 1 extended and then use the extended one to house multiple logical partitions.
  • 4. Lack of safety and security mechanisms.

MBR is the default compliant partition table that works with BIOS (or legacy BIOS) based systems.

OS installations

On MBR based drive, the first 446 bytes contain the executable bootstrap code (also called the Stage 1 boot-loader).

This boot-loader executes and loads the Stage 2 boot-loader which resides in /boot/grub for example.

On GRUB based linux installations MBR boot-loader contains the executable code from the file "boot.img".

It is important to note that MBR based os installation drives will work with both legacy BIOS as well as UEFI "bios". However there is a catch.

Linux can work with UEFI + MBR drive.
Windows 10 cannot work with UEFI "bios" + MBR drive, but Windows 10 can work with Legacy Bios + MBR drive.

Reading the MBR

If you are curious enough and want to see how the MBR looks on your os boot drive here are some ways to do it on linux. You can simply dump the raw contents of the boot drive taking only 512 bytes (that is 1 sector and the total size of MBR)

Here is how it looks on my system.

$ sudo hd -n 512 /dev/sda
00000000  eb 63 90 10 8e d0 bc 00  b0 b8 00 00 8e d8 8e c0  |.c..............|
00000010  fb be 00 7c bf 00 06 b9  00 02 f3 a4 ea 21 06 00  |...|.........!..|
00000020  00 be be 07 38 04 75 0b  83 c6 10 81 fe fe 07 75  |....8.u........u|
00000030  f3 eb 16 b4 02 b0 01 bb  00 7c b2 80 8a 74 01 8b  |.........|...t..|
00000040  4c 02 cd 13 ea 00 7c 00  00 eb fe 00 00 00 00 00  |L.....|.........|
00000050  00 00 00 00 00 00 00 00  00 00 00 80 01 00 00 00  |................|
00000060  00 00 00 00 ff fa 90 90  f6 c2 80 74 05 f6 c2 70  |...........t...p|
00000070  74 02 b2 80 ea 79 7c 00  00 31 c0 8e d8 8e d0 bc  |t....y|..1......|
00000080  00 20 fb a0 64 7c 3c ff  74 02 88 c2 52 bb 17 04  |. ..d|<.t...R...|
00000090  f6 07 03 74 06 be 88 7d  e8 17 01 be 05 7c b4 41  |...t...}.....|.A|
000000a0  bb aa 55 cd 13 5a 52 72  3d 81 fb 55 aa 75 37 83  |..U..ZRr=..U.u7.|
000000b0  e1 01 74 32 31 c0 89 44  04 40 88 44 ff 89 44 02  |[email protected].|
000000c0  c7 04 10 00 66 8b 1e 5c  7c 66 89 5c 08 66 8b 1e  |....f..\|f.\.f..|
000000d0  60 7c 66 89 5c 0c c7 44  06 00 70 b4 42 cd 13 72  |`|f.\..D..p.B..r|
000000e0  05 bb 00 70 eb 76 b4 08  cd 13 73 0d 5a 84 d2 0f  |...p.v....s.Z...|
000000f0  83 d0 00 be 93 7d e9 82  00 66 0f b6 c6 88 64 ff  |.....}...f....d.|
00000100  40 66 89 44 04 0f b6 d1  c1 e2 02 88 e8 88 f4 40  |@f.D...........@|
00000110  89 44 08 0f b6 c2 c0 e8  02 66 89 04 66 a1 60 7c  |.D.......f..f.`||
00000120  66 09 c0 75 4e 66 a1 5c  7c 66 31 d2 66 f7 34 88  |f..uNf.\|f1.f.4.|
00000130  d1 31 d2 66 f7 74 04 3b  44 08 7d 37 fe c1 88 c5  |.1.f.t.;D.}7....|
00000140  30 c0 c1 e8 02 08 c1 88  d0 5a 88 c6 bb 00 70 8e  |0........Z....p.|
00000150  c3 31 db b8 01 02 cd 13  72 1e 8c c3 60 1e b9 00  |.1......r...`...|
00000160  01 8e db 31 f6 bf 00 80  8e c6 fc f3 a5 1f 61 ff  |...1..........a.|
00000170  26 5a 7c be 8e 7d eb 03  be 9d 7d e8 34 00 be a2  |&Z|..}....}.4...|
00000180  7d e8 2e 00 cd 18 eb fe  47 52 55 42 20 00 47 65  |}.......GRUB .Ge|
00000190  6f 6d 00 48 61 72 64 20  44 69 73 6b 00 52 65 61  |om.Hard Disk.Rea|
000001a0  64 00 20 45 72 72 6f 72  0d 0a 00 bb 01 00 b4 0e  |d. Error........|
000001b0  cd 10 ac 3c 00 75 f4 c3  03 46 01 00 00 00 80 20  |...<.u...F..... |
000001c0  21 00 83 fe ff ff 00 08  00 00 00 b8 eb 0b 00 00  |!...............|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200

Or use the command

dd if=/dev/sda bs=512 count=1 | hexdump -C

The boot-loader code present in the mbr actually comes from the boot.img file inside grub. You might want to take a look at that as well:
On my system the file is located at /boot/grub/i386-pc/boot.img

Read the boot.img

enlightened@enlightened:/boot/grub/i386-pc$ sudo hd -n 512 boot.img 
00000000  eb 63 90 00 00 00 00 00  00 00 00 00 00 00 00 00  |.c..............|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000050  00 00 00 00 00 00 00 00  00 00 00 80 01 00 00 00  |................|
00000060  00 00 00 00 ff fa eb 05  f6 c2 80 74 05 f6 c2 70  |...........t...p|
00000070  74 02 b2 80 ea 79 7c 00  00 31 c0 8e d8 8e d0 bc  |t....y|..1......|
00000080  00 20 fb a0 64 7c 3c ff  74 02 88 c2 52 bb 17 04  |. ..d|<.t...R...|
00000090  f6 07 03 74 06 be 88 7d  e8 17 01 be 05 7c b4 41  |...t...}.....|.A|
000000a0  bb aa 55 cd 13 5a 52 72  3d 81 fb 55 aa 75 37 83  |..U..ZRr=..U.u7.|
000000b0  e1 01 74 32 31 c0 89 44  04 40 88 44 ff 89 44 02  |[email protected].|
000000c0  c7 04 10 00 66 8b 1e 5c  7c 66 89 5c 08 66 8b 1e  |....f..\|f.\.f..|
000000d0  60 7c 66 89 5c 0c c7 44  06 00 70 b4 42 cd 13 72  |`|f.\..D..p.B..r|
000000e0  05 bb 00 70 eb 76 b4 08  cd 13 73 0d 5a 84 d2 0f  |...p.v....s.Z...|
000000f0  83 d0 00 be 93 7d e9 82  00 66 0f b6 c6 88 64 ff  |.....}...f....d.|
00000100  40 66 89 44 04 0f b6 d1  c1 e2 02 88 e8 88 f4 40  |@f.D...........@|
00000110  89 44 08 0f b6 c2 c0 e8  02 66 89 04 66 a1 60 7c  |.D.......f..f.`||
00000120  66 09 c0 75 4e 66 a1 5c  7c 66 31 d2 66 f7 34 88  |f..uNf.\|f1.f.4.|
00000130  d1 31 d2 66 f7 74 04 3b  44 08 7d 37 fe c1 88 c5  |.1.f.t.;D.}7....|
00000140  30 c0 c1 e8 02 08 c1 88  d0 5a 88 c6 bb 00 70 8e  |0........Z....p.|
00000150  c3 31 db b8 01 02 cd 13  72 1e 8c c3 60 1e b9 00  |.1......r...`...|
00000160  01 8e db 31 f6 bf 00 80  8e c6 fc f3 a5 1f 61 ff  |...1..........a.|
00000170  26 5a 7c be 8e 7d eb 03  be 9d 7d e8 34 00 be a2  |&Z|..}....}.4...|
00000180  7d e8 2e 00 cd 18 eb fe  47 52 55 42 20 00 47 65  |}.......GRUB .Ge|
00000190  6f 6d 00 48 61 72 64 20  44 69 73 6b 00 52 65 61  |om.Hard Disk.Rea|
000001a0  64 00 20 45 72 72 6f 72  0d 0a 00 bb 01 00 b4 0e  |d. Error........|
000001b0  cd 10 ac 3c 00 75 f4 c3  00 00 00 00 00 00 24 12  |...<.u........$.|
000001c0  0f 09 00 52 be bd 7d 31  c0 cd 13 46 8a 0c 84 c9  |...R..}1...F....|
000001d0  75 0f be da 7d e8 da ff  eb a4 46 6c 6f 70 70 79  |u...}.....Floppy|
000001e0  00 bb 00 70 8e c3 31 db  b8 01 02 b5 00 b6 00 cd  |...p..1.........|
000001f0  13 72 d4 b6 01 b5 4f e9  ff fe 00 00 00 00 55 aa  |.r....O.......U.|
00000200
enlightened@enlightened:/boot/grub/i386-pc$

Note how similar they look.

GPT drive based OS installations

GPT is the new-age partition table scheme that overcomes the limitations of mbr. GPT is also a part of the "UEFI technology" package and is recommended for most modern system, but it is NOT a strict requirement.

Possible configurations of OS installs:

  • You can have UEFI (Legacy BIOS mode/CSM) + MBR drive for os installation. Linux supports this, but not Windows 10.
  • You can have UEFI (Legacy BIOS mode/CSM) + GPT drive for os installation.
  • You can have UEFI + GPT drive for os installation. This is the modern recommended approach.

Can Legacy BIOS systems boot OS on a GPT drive ?

Yes, Legacy BIOS can use GPT drive to boot the OS, but it would need a dedicated BIOS Boot partition.

Old BIOS recognises only MBR and not GPT. However since GPT drives also have a "protected MBR" for backward compatibility, the mbr boot record is made to point to a dedicated BIOS-Boot partition which contains the next stage of boot loader.

On linux systems, GRUB2 stores the core.img code in BIOS-Boot partition which can be thought of as Stage 1.5 Boot-loader whose job is to prepare the system and load Stage 2 boot-loader which is at "/boot/grub".

Gparted GPT DIsk Partitions - Ubuntu with ESP

Gparted GPT DIsk Partitions - Ubuntu with ESP

THe above system has Windows 10 + Ubuntu in dual boot configuration on a single nvme ssd on a laptop. The very first partition is a EFI System partition with "boot" and "esp" flags on it.

The same data can viewed with the parted command in a neat format on the command line:

acerlight@acerlight-laptop:~$ sudo parted -l
[sudo] password for acerlight: 
Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/encryptedhome: 102GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End    Size   File system  Flags
 1      0.00B  102GB  102GB  ext4


Model: HFM512GDJTNI-82A0A (nvme)
Disk /dev/nvme0n1: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size    File system     Name                          Flags
 1      1049kB  106MB  105MB   fat32           EFI system partition          boot, esp
 2      106MB   123MB  16.8MB                  Microsoft reserved partition  msftres
 3      123MB   215GB  215GB   ntfs            Basic data partition          msftdata
 5      215GB   297GB  81.9GB  ext4
 6      297GB   399GB  102GB
 7      399GB   416GB  16.4GB  linux-swap(v1)                                swap
 8      457GB   511GB  53.7GB  ntfs                                          msftdata
 4      511GB   512GB  1074MB  ntfs            Basic data partition          hidden, diag


acerlight@acerlight-laptop:~$

The 215GB "msftdata" partition is where Windows 10 is installed. Note that a partition starts at the point where the preceding the partition ends. However the first partition which is the EFI System partition starts at 1049kB mark. This indicates that the part before that is the GPT header which is hidden from the parted command output

Dual Boot Considerations

If you want to setup dual boot on your desktop or laptop using Windows 10 and Ubuntu for instance, there are certain important factors that come into play with regards to booting technologies discussed above.

Firstly all the oses on a system must be installed/configured to use the same boot methods. Either all should be BIOS+MBR or all should be UEFI/ESP based. This is because the boot process "control flow" of each technology is very different.

Take a look at this simple diagram.

Consider the following scenarios:

1. You got a Windows 10 laptop which is already pre-installed with UEFI boot, ESP and gpt partition. Now if you install Ubuntu on it, Ubuntu must also use ESP and install the GRUB boot loader in the ESP partition. You cannot use Legacy BIOS methods for booting Ubuntu.

2. If you have a desktop with Windows 10 booting with BIOS+MBR then you must install the next OS to use BIOS only. When Ubuntu uses legacy MBR based booting the GRUB boot-loader is placed in a special path "/boot" which can be on the root partition or on a separate partition.

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

Leave a Reply

Your email address will not be published. Required fields are marked *