All Products
Search
Document Center

Elastic Compute Service:Convert MBR partitions into GPT partitions

Last Updated:Feb 22, 2024

This topic describes how to convert the Master Boot Record (MBR) partitions of a data disk on a Linux or Windows Elastic Compute Service (ECS) instance to GUID Partition Table (GPT) partitions.

Scenarios

The MBR partition style does not support disks larger than 2 TiB in size. If you want to extend an MBR disk to more than 2 TiB, you must convert the disk into a GPT disk first.

Convert a data disk on a Linux instance from MBR to GPT

Perform the following steps to convert a data disk on a Linux instance from MBR to GPT. In the examples of this section, an Alibaba Cloud Linux 2.1903 LTS 64-bit public image and the data disk /dev/vdb are used. Operations may vary based on the image and data disk of your instance.

  1. Optional: Create a snapshot for the data disk that you want to convert from MBR to GPT to back up disk data.

    For more information, see Create a snapshot for a disk.

    Note
    • In normal cases, when you convert an MBR disk on a Linux instance into a GPT disk, the data on the original disk partitions is not lost. To prevent data loss or exceptions caused by accidental operations, we recommend that you back up disk data beforehand.

    • You are charged for the snapshot. For more information, see Snapshots.

  2. Connect to the instance.

  3. Run the following command to check the partitions on the disk:

    fdisk -lu

    Check the partitions on the diskThe command output shown in the preceding figure indicates that the instance has two disks attached: the system disk /dev/vda and the data disk /dev/vdb. In the examples, the data disk /dev/vdb is converted from MBR to GPT. In the command output, take note of the following settings:

    • ①: the device name of the data disk

    • ②: the partition style of the data disk

      The valid values of Disk label type are dos and gpt. dos indicates the MBR partition style, and gpt indicates the GPT partition style.

      Note
      • The values vary based on the operating system. If the Disk label type field is not displayed, check the System field to determine the partition style. If the value of System is Linux, the MBR partition style is used. If the value is GPT, the GPT partition style is used.

      • If you use an earlier version of fdisk, the GPT partition style may not be displayed. You can run the gdisk -l /dev/vdb command to check the partition style.

  4. Run the following command to install the gdisk utility.

    • If the instance runs Alibaba Cloud Linux 2, Alibaba Cloud Linux 3, or CentOS 6 or later, run the following command:

      type sgdisk || yum install -y gdisk
    • If the instance runs Debian 8 or later, or Ubuntu 14 or later, run the following command:

      type sgdisk || apt-get install -y gdisk
  5. Run the following command to convert the data disk from MBR to GPT.

    To convert the /dev/vdb disk from MBR to GPT, run the following command:

    sgdisk -g /dev/vdb
    Note

    If an error is reported, resolve the error as described in the FAQ section of this topic.

  6. Run the following command to check whether the disk is converted from MBR to GPT.

    To check whether the /dev/vdb disk is converted from MBR to GPT, run the following command:

    fdisk -lu /dev/vdb

    In the command output shown in the following figure, Disk label type has a value of gpt, which indicates that the disk is converted to GPT. New partition

    Note

    The command output varies slightly based on operating systems. If the Disk label type parameter is not present in the command output, you can check the System parameter to determine whether the disk is converted to GPT. If System has a value of GPT, it indicates that the disk is a GPT disk.

Convert a data disk on a Windows instance from MBR to GPT

Perform the following steps to convert a data disk on a Windows instance from MBR to GPT. In the examples of this section, a Windows Server 2012 R2 64-bit public image and the data disk Disk 1 are used. Operations may vary based on the image and data disk of your instance.

Important

When you convert a data disk on a Windows instance from MBR to GPT, the data on the disk is temporarily unavailable. If services that are running on the instance depend on the data on the disk, issues may occur. We recommend that you stop services beforehand and then resume the services after the disk is converted to GPT and has its data restored.

Step 1: Convert the disk from MBR to GPT

  1. Optional: Back up the data on the disk.

    Warning

    When you convert a disk on a Windows instance from MBR to GPT, if you delete a volume, all data on the volume is cleared. Back up the data on the disk beforehand.

    After the disk is converted to GPT, you can restore the backup data of the original disk. You can use one of the following methods to back up the data on the disk:

    • Method 1: Create a snapshot for the disk.

      Note

      You are charged for the snapshot. For more information, see Snapshots.

      1. Create a snapshot for the disk. For more information, see Create a snapshot for a disk.

      2. Create a disk from the snapshot and attach this new disk to the instance. For more information, see Create a disk from a snapshot and Attach a data disk.

    • Method 2: Manually copy the data on the disk to another disk on the instance.

  2. Connect to the instance.

  3. On the Windows Server desktop, right-click the Start icon icon and select Disk Management.

  4. Find the data disk that you want to convert from MBR to GPT. In this example, Disk 1 is used.

    Disk 1

  5. Right-click a simple volume and select Delete Volume.

    Delete Volume

    Important

    If the volume cannot be deleted, it may be because specific programs on the instance are accessing the data or information of the volume. Restart the instance and then delete the volume. Instance restarts may interrupt services. We recommend that you restart instances during an appropriate period of time.

  6. In the Delete simple volume message, click Yes.

  7. Right-click a blank area next to Disk 1 and select Convert to GPT Disk.

    Convert to GPT Disk

  8. Right-click the Unallocated section and select New Simple Volume.

    New Simple Volume

  9. In the New Simple Volume Wizard window, click Next and complete settings as instructed.

    1. In the Specify Volume Size step, set Simple volume size in MB and click Next.

      If you want to create only a single primary partition on the disk, use the default value. You can also specify a simple volume size based on your needs to divide Disk 1 into multiple partitions. Specify Volume Size

    2. In the Assign Drive Letter or Path step, select Assign the following drive letter, select a drive letter (example: D), and then click Next.

      Assign drive letters

    3. In the Format Partition step, select Format this volume with the following settings, configure formatting settings, and then click Next.

      Configure formatting settings

    4. View the information of the new simple volume and then click Finish to close the New Simple Volume Wizard window.

    The following figure shows the state of Disk 1 in the Disk Management window after the disk is converted. New disk status

Step 2 (Optional): Restore the data on the original disk

If you have backed up the data on the original disk and want to restore the data, manually copy the data to the disk after the disk is converted to GPT. Then, make sure that the data is correct before you use the data.

Note

If you restore the data on the original disk from a snapshot, we recommend that you delete the snapshot after disk data is restored to prevent additional charges. For more information, see Delete a snapshot.

FAQ

Problem: When you run the sgdisk -g command to convert a disk from MBR to GPT, the following message appears:

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: With less than 33 free sectors at the end of the disk, the disk does not have enough space for the conversion from MBR to GPT.

Solution: Resize the disk by extending the capacity in the ECS console and convert the disk from MBR to GPT. For information about how to resize a disk, see Step 1: Resize a disk to extend its capacity.