All Products
Search
Document Center

Elastic Compute Service:Convert MBR partitions into GPT partitions

Last Updated:Mar 12, 2024

The Master Boot Record (MBR) partition style does not support disks that are larger than 2 TiB in size. Before you extend an MBR disk to more than 2 TiB, convert the disk into a GUID Partition Table (GPT) disk. This topic describes how to convert the MBR partitions of a data disk on a Linux or Windows Elastic Compute Service (ECS) instance into GPT partitions.

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 3.2104 LTS 64-bit public image and a data disk whose device name is /dev/vdb are used. The operations may vary based on the image and 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 most cases, data that is stored on the original disk partitions is not lost when you convert an MBR disk on a Linux instance into a GPT disk. To prevent data loss or exceptions caused by accidental operations, we recommend that you back up disk data in advance.

    • You are charged for the snapshot. For more information, see Billing of snapshots.

  2. Connect to the instance.

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

    sudo fdisk -lu

    image

    The command output shown in the preceding figure indicates that the instance has two disks: the system disk whose device name is /dev/vda and the data disk whose device name is /dev/vdb. In the examples, the /dev/vdb data disk is used. Take note of the following information that is contained in the command output:

    • ①: the device name of the data disk

    • ②: the partition style of the data disk

      If the value of Disklabel type is dos, the MBR partition style is used. If the value is gpt, the GPT partition style is used.

      Note
      • The command output varies based on the operating system. If the Disklabel 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 sudo gdisk -l /dev/vdb command to check the partition style.

  4. Run one of the following commands based on the instance operating system 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 || sudo yum install -y gdisk
    • If the instance runs Debian 8 or later, or Ubuntu 14 or later, run the following command:

      type sgdisk || sudo apt-get install -y gdisk
  5. Convert the data disk from MBR to GPT.

    Important

    sgdisk can be used to perform operations only on disks, such as /dev/vdb. If you use sgdisk to perform operations on a partition such as /dev/vdb1, the file system of the partition may be corrupted.

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

    sudo sgdisk -g /dev/vdb

    image

    Note

    If an error occurs when you run the sgdisk command, resolve the issue based on the error message that is returned. For more information, see the Issues section in this topic.

  6. 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:

    sudo fdisk -lu /dev/vdb

    In the command output shown in the following figure, the value of Disklabel type is gpt, which indicates that the disk is converted to GPT.

    image

    Note

    The command output varies based on the operating system. If the Disklabel type field is not included in the command output, you can check the System field to determine whether the disk is converted to GPT. If the value of System is GPT, the disk is converted to GPT.

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 2016 64-bit public image and the data disk Disk 1 are used. The operations may vary based on the image and disk of your instance.

Important

When you convert a data disk on a Windows instance from MBR to GPT, the data that is stored on the disk is temporarily unavailable. If services that are running on the instance depend on the data that is stored on the disk, issues may occur. Before you convert the disk from MBR to GPT, we recommend that you stop the services on the instance. After the disk is converted to GPT and the data that was stored on the disk is restored, resume the services.

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, all data that is stored on a volume is cleared if you delete the volume. We recommend that you back up the data that is stored on the disk in advance.

    After the disk is converted to GPT, you can restore the data of the original disk from the backup. 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 Billing of snapshots.

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

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

    • Method 2: Copy data from the disk to another disk on the instance.

  2. Connect to the instance.

  3. On the Windows desktop, right-click the 开始图标 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.

    磁盘1

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

    删除卷

    Important

    If you cannot delete the volume, specific programs on the instance may be 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.

    转换GTP

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

    新建简单卷

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

    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.指定卷大小

    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.

      分配驱动号

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

      设置格式化信息

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

    The following figure shows the status of Disk 1 in the Disk Management window after the disk is converted.新磁盘状态

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

If you have backed up the data that was stored on the original disk and want to restore the data, copy the backed-up data to the disk after the disk is converted to GPT. Make sure that the restored data is correct before you use the data.

Note

If you restore the data that was stored on the original disk from a snapshot, we recommend that you delete the snapshot after the data is restored to prevent unnecessary charges. For information about how to delete a snapshot, see Delete a snapshot.

Issues

  1. 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: Fewer than 33 free sectors exist at the end of the disk, and the disk has insufficient space for the conversion from MBR to GPT.

    Solution: Resize the disk by extending the disk capacity in the ECS console and then 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.

  2. Problem: When you run the sgdisk -g command to convert a disk on an ECS instance from MBR to GPT, the following message appears:

    image

    Cause: The disk header has insufficient space to accommodate the required GPT partition table header information. In most cases, when data or partitions are located near the beginning of the disk, the space for the GPT partition table structure is insufficient. In this case, you cannot convert the disk from MBR to GPT.

    Solution:

    1. Create a snapshot for the disk to back up data. For more information, see Create a snapshot for a disk.

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

    3. Run a rsync command to copy the data of the original disk to the new disk.

    4. Detach and delete the original disk. For more information, see Detach a data disk and Release a disk.