Converting MBR partitions to GPT format

2 min read

The Master Boot Record (MBR) partition format is being replaced by the newer GUID Partition Table (GPT) standard, but MBR is still widely used as the default format. The GPT format offers numerous advantages for partition tables compared to MBR. As well as supporting significantly larger (2T+) disks, it enables faster and more stable system boot-up.

Switch to the root user (or log in as the root user)

sudo su -

If the gdisk application is not already installed, please install it.

yum install gdisk

Let’s launch the GPT partitioning tool, the gdisk utility. You need to specify the disk path as a parameter; for example, if your disk is sda, then as follows:

gdisk /dev/sda

After starting up, it displays a message explaining the situation; in this case, it has only found an MBR.

GPT fdisk (gdisk) version 0.8.10

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

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************

Check that there is sufficient space before the first partition to create the BIOS boot partition. If the first sector of the first partition starts at sector number 2048 (or higher), then everything will be fine. Type the letter ‘p’ and press Enter to display the partition table.

Command (? for help): p

Disk /dev/sda: 52428800 sectors, 25.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 71DD2E79-BD1C-4713-9880-22664C87E57B
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 52428766
Partitions will be aligned on 2048-sector boundaries
Total free space is 20973501 sectors (10.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2099199   1024.0 MiB  8300  Linux filesystem
   2         2099200        16777215   7.0 GiB     8E00  Linux LVM
   3        16777216        20971519   2.0 GiB     8E00  Linux LVM
   4        20971520        31457279   5.0 GiB     8E00  Linux LVM

Let’s create the BIOS boot partition before the existing first partition. The start sector will be 34, the end sector 2047, and the type will be ef02

Command (? for help): n

Partition number (5-128, default 5):
First sector (34-52428766, default = 31457280) or {+-}size{KMGTP}: 34
Last sector (34-2047, default = 2047) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef02
Changed type of partition to 'BIOS boot partition'

Save the changes by pressing the w key.

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.

Next, reload the partition table so that Linux can apply the changes

partprobe

Finally, let’s reinstall GRUB on the sda drive

grub2-install /dev/sda

Finally, let’s restart Linux.

Back to the blog