All Products
Search
Document Center

:Convert an MBR partition to a GPT partition

Last Updated:Aug 07, 2025

The Master Boot Record (MBR) partition format does not support disks larger than 2 TiB. If your disk uses the MBR partition format and you want to resize it to be larger than 2 TiB, you must first convert the partition format from MBR to GPT. After the conversion, you can resize the partition and file system.

Preparations

Procedure

  1. (Optional) Create a snapshot of the disk to back up your data.

    Note

    Data is not typically lost during the conversion. However, we recommend that you back up your data in advance to prevent data loss that may be caused by incorrect operations.

  2. Connect to an RDS Custom instance.

  3. Run the following command to install the gdisk tool.

    • For Alibaba Cloud Linux 2/3, CentOS 7, and later versions, run the following command.

      type sgdisk || sudo yum install -y gdisk
    • For Debian 11, Ubuntu 14, and later versions, run the following command.

      type sgdisk || sudo apt-get install -y gdisk
  4. Run the following command to convert the partition format from MBR to GPT.

    Warning

    The sgdisk command can be used only for disks, such as /dev/nvme2n1. It cannot be used for partitions, such as /dev/nvme2n1p1. Otherwise, the file system may be corrupted.

    In this example, the disk is /dev/nvme2n1. Replace /dev/nvme2n1 with the actual device name of your disk.

    sudo sgdisk -g /dev/nvme2n1

    In the command, -g converts the MBR partition to a GPT partition and retains the original MBR backup.

    If the message successfully is returned, the conversion is successful.

    Note

    If an error is reported when you run the sgdisk command, see the FAQ section for troubleshooting information.

  5. Run the following command to verify the partition conversion.

    In this example, the disk name is /dev/nvme2n1. Replace this with your actual disk name.

    sudo fdisk -lu /dev/nvme2n1

    If Disklabel type is set to gpt, the partition is converted to the GPT format.

What to do next

Resize the partition and file system

FAQ

  1. Problem: The following message is returned when you run the sgdisk -g command to convert a partition.

    Warning! Secondary partition table overlaps the last partition by 33 blocks!
    You will need to delete this partition or resize it in another utility.

    Cause: The remaining space at the end of the disk is less than 33 sectors. This means there is not enough space to convert the MBR partition to a GPT partition.

    Solution: First, resize the disk, and then convert the partition format.

  2. Problem: The following message is returned when you run the sgdisk -g command to convert a partition.

    Warning! Main partition table overlaps the first partition by 24 blocks! 
    Try reducing the partition table size by 96 entries.
    (Use the 's' item on the experts' menu.)
    Warning! Main partition table overlaps the first partition by 24 blocks! 
    Try reducing the partition table size by 96 entries.
    (Use the 's' item on the experts' menu.)
    Aborting write of new partition table.

    Cause: The remaining space at the beginning of the disk is insufficient for the header required by the GPT partition table. This issue usually occurs because data or a partition is located at the very beginning of the disk, leaving no space for the GPT partition table structure. In this case, partition conversion is not supported.

    Solution:

    1. Create a snapshot of the disk.

    2. Create a new disk and attach it to the RDS Custom instance.

    3. Run the rsync command to copy data from the old disk to the new disk.

    4. Detach and release the old disk.

  3. Problem: The following message is returned when you run the type sgdisk || sudo yum install -y gdisk command.

    Error downloading packages:
      gdisk-0.8.10-3.1.al7.x86_64: Insufficient space in download directory /var/cache/yum/x86_64/2.1903/updates/packages
        * free   0
        * needed 190 k

    Cause: The download folder (`/var/cache/yum/x86_64/2.1903/updates/packages`) does not have enough space to download the required package.

    Solution: You must clear space to increase the available storage in the download folder.

References

Introduction to RDS Custom