All Products
Search
Document Center

Elastic Compute Service:Convert MBR partitions into GPT partitions

Last Updated:Dec 12, 2024

The Master Boot Record (MBR) partition style does not support disks that are larger than 2 TiB in size. After you extend a disk to more than 2 TiB, convert the disk from MBR to GUID Partition Table (GPT) and extend the partitions and system files. 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.

Preparations

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, a data disk whose device name is /dev/vdb is 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.

    Log on to the ECS console, click Instances in the left-side navigation pane, select the instance you want to manage on the Instance page, and click Connect in the Actions column. For more information, see Use Workbench to connect to a Linux instance over SSH.

  3. 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
  4. 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. -g indicates an MBR-to-GPT conversion.

  5. 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.

    • If data anomalies occur after you convert the disk, use a snapshot to roll back the disk to the state at the point of time when the snapshot was created. For more information, see Roll back a disk by using a snapshot.

  6. After the disk is converted from MBR to GPT, extend the partitions and file systems. For more information, see Extend the partitions and file systems of disks on a Linux instance.

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
    • Method 2: Copy data from the disk to another disk on the instance.

  2. Connect to the instance.

    Log on to the ECS console, click Instances in the left-side navigation pane, select the instance you want to manage on the Instance page, and click Connect in the Actions column. For more information, see Use Workbench to connect to a Windows instance over RDP.

  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. After all simple volumes are deleted from Disk 1, right-click a blank area next to Disk 1, and select Convert to GPT Disk.

    转换GTP

  8. Righ-click the disk and choose Properties > Volumes to view Partition style. Check whether the prtition style is converted as expected.截屏2024-10-30 15

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

    新建简单卷

  10. 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, take note of the following items:

  • You must create a disk from the snapshot, attach the disk to the instance, and then copy data to the new disk. Do not use the snapshot to directly roll back the disk to the MBR format. For more information, see Create a disk from a snapshot and Attach a data disk.

  • 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.

Step 3: Extend the partitions and system files

After the disk is converted from MBR to GPT, you can extend the partitions and file systems. For more information, see Extend the partitions and file systems of disks on Windows instances.

Issues

  1. Issue: 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. Issue: 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.

  3. Issue: When the type sgdisk || yum install -y gdisk command is run, the following error message is returned:

    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 directory of /var/cache/yum/x86_64/2.1903/updates/packages has insufficient space to store the downloaded package.

    Solution: Clean the space to provide sufficient space to store the downloaded package.