MBR vs GPT-partition considerations (screenshot)

As technology advances, there are many ways to store and organize data. This has led to new devices with large storage capacities. To manipulate such a large capacity, you will need to use the appropriate partition table on your hard drive.

When you consider preserving data, two popular formats, GPT and MBR, are used before choosing a file system. As a system administrator, you may want to use MBR (Master Boot Record) or GPT (GUID Partition Table) when partitioning, so you must understand the difference between the two.

In order to properly understand how they work, in this tutorial we will need to explore some basic concepts about MBR and GPT to understand their advantages, limitations and differences.

What to know

A partition is defined by a data structure written to a specified portion of the hard disk. Must be used when you have to store partition information on the drive MBR Either GPT It tells the operating system exactly where and where to start a partition, which sector belongs to each partition, and which partition is bootable. This is one of the main reasons we have to choose between MBR and GPT before creating a partition on our hard drive.

Many computers are compatible with both, but they do not work together. Generally, MBR is an older version that has been used before and it can be used with BIOS system. GPT is the new version that accompanies UEFI (Unified Extensible Firmware Interface) system. So this means that if you are installing an operating system on your hard drive and choose to use MBR, GPT will not work and vice versa. A conversion from one to the other is possible, but the process will result in the deletion of everything on the disk.

1- MBR

MBR For Master boot record Store its data in the first sector of the disk and include partition and file system information to tell the BIOS that this is the boot drive and where to find the mountable file system. You should note that MBR only supports drives up to 2TB. To run on MBR disk, you need to use fdisk, cfdisk, Or parted command

MBR compatibility comes with system installation Legacy BIOS The mode is in the BIOS configuration. This means that you know at the beginning whether to perform an MBR installation. For example, on Ubuntu, if it appears purple when starting the installation, then it is an MBR installation

Install MBR on Ubuntu

If you have installed a Linux system (such as Ubuntu) and want to check if it is MBR, you can use gdisk -l command

Check MBR partition with gdisk command

This way, you can confirm that you are using MBR.

MBR architecture has its particularity, because usually it only supports 4 primary partitions. It can support up to four partitions, but there is a special condition that meets this requirement:

  • The first three partitions should be Primary partition,
  • The last partition should be Extended partition Can be subdivided into smaller partitions called Logical partition.

A device file with a primary partition is appended with a number indicating the partition on that hard disk. The first primary partition is numbered 1, the second primary partition is numbered 2, the third primary partition is numbered 3, and the fourth primary partition is numbered 4. When owning an extended partition, the volume within the logic starts with the number 5

We can check for example fdisk -l Commands on another MBR disk with primary and extended partitions

# fdisk -l
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0000996b

Device     Boot      Start        End      Blocks   Id  System
/dev/sda1            2048     4196351     2097152   82  Linux swap / Solaris
/dev/sda2   *     4196352    30679039    13241344   83  Linux
/dev/sda4        30679040    41164799     5242880    5  Extended
/dev/sda5        30681088    36540415     2929664   83  Linux

In order to understand the limitations of the four primary partitions correctly, let’s take manual partitioning during the Ubuntu installation process as an example. For this example, suppose we want to create 5 partitions during this process:

  • We will first create /boot Partition as primary partition

Creation of the primary MBR boot partition

  • Let’s do the same for the following partitions /, /home, /opt By making them primary partitions. This means we will have 04 primary partitions. We will see that the remaining space will be unusable due to the MBR partition number limitation.

Up to 04 primary MBR primary partitions

You will see that after reaching the limit of 04 MBR primary partitions, we are unable to add new partitions.

Another special feature of MBR is that a single bit error can render the disk useless. For these reasons, and more, the Unified Extensible Firmware Interface (UEFI) specifies the replacement of MBR with a GUID Partition Table (GPT), thereby overcoming these limitations.

2- GPT

GPT For GUID partition table It is part of the Intel EFI specification. GPT and MBR formats are different, but for compatibility reasons, MBR is stored in the first logical block and GPT is stored in the second logical block. GPT allows disks with more than 2 TB and up to 128 partitions.

To run on a GPT disk, you need to use gdisk Either parted command. of gdisk Works with GPT fdisk and uses a very similar interface to fdisk.

To install the system on a GPT disk, it must be enabled Unified Extensible Firmware Interface (UEFI) In the BIOS configuration. For example, if you want to install Ubuntu on your computer, there will be a black background color at startup, as shown below

Install GPT on Ubuntu

If you want to check if you are using GPT partition, please still use gdisk -l command

Check GPT partition with gdisk command

of Mbr: protective This is because GPT uses protective MBR, which is a legal definition of MBR, which makes utilities that GPT does not understand think that the disk has an MBR partition that spans the entire disk.

With GPT, no primary extended partition or logical drive is required, which means that all partitions are the same. Of course, you can still consider using Primary for a better understanding. However, in practice, GPT partitions are usually numbered consecutively from 1 even though some gaps may appear in the partition numbering. Let’s take a look at another disk using GPT

# gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 02F5A939-659C-46B7-8392-40F60B005D04
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 4077 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   EF00  
   2         1050624        99878911   47.1 GiB    8300  
   3        99878912       138940415   18.6 GiB    8300  
   4       138940416       155541503   7.9 GiB     8200  
   5       155541504       184838143   14.0 GiB    8300  
   6       184838144       595970047   196.0 GiB   8300  
   7       595970048       976771071   181.6 GiB   8300  DATA

You can see that we no longer mention extensions, but just a list or many partitions, and fortunately we have no gaps in the numbering.

Now, let’s try to create more than four partitions while installing examples (such as Ubuntu). So we will also start to create /boot Divide

Create tge GPT boot partition

Now do the same for other partitions /, /home, /tmp, /var

Create additional GPT partitions

As you can see, we have 05 GPT primary partitions, and it is possible to create more partitions using recognized free space.

in conclusion

As a system administrator, you should at least have some knowledge of GPT, because MBR cannot handle disks larger than 2TiB. Even if the two are different, keep the similarities to ensure compatibility. Linux servers usually have multiple hard drives, so it is important to understand that large hard drives with more than 2TB and many newer hard drives use GPT instead of MBR to allow additional addressing of sectors.