Converting Disk from MBR to GPT on Linux

PowerADM.com / Linux / CentOS / Converting Disk from MBR to GPT on Linux

To find out the type of partition table on a disk in Linux, run the command

$ sudo parted /dev/sdb print

Partition table = msdos indicates that the disk uses an MBR partition table.

View the Partition Table in Linux

In Linux, it is possible to change the type of partitioning table used on a disk without losing any data (however, it is advisable to back up important data before proceeding). Use the gdisk tool to change the partition table.

Install the gdisk tool on your Linux distro

  • CentOS, RedHat, Oracle/Rocky Linux: $ sudo yum -y install gdisk
  • Ubuntu, Debian: $ sudo apt install gdisk

To change the partition table of the /dev/sdb disk, execute the following command:

$ sudo gdisk /dev/sdb

Type w -> Enter

Confirming the conversion of the partition table from MBR to GPT, which will not impact the existing partitions on the disk.

fdisk: convert mbr to gpt

Update disk partition info:

$ sudo partprobe /dev/sda

Check that the disk partition table type has been changed to GPT.

$ sudo parted /dev/sdb print

gpt partition on linux

When converting from MBR to GPT, an error may occur:

Warning! Secondary partition table overlaps the last partition by 33 blocks!

This indicates insufficient unallocated space on your disk to duplicate the GPT partition table at the end of the disk. In this case, it is necessary to shrink the size of the current partition or increase the disk capacity.

To convert a partition table from GPT to MBR:

$ sudo gdisk /dev/sdb

Then run sequentially:

r
g
w
y

You can re-install the GRUB bootloader on /dev/sdb:

$ sudo grub-install /dev/sdb

To make the new drive bootable, create a separate EFI System Partition (ESP).

Leave a Reply

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