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
Extend the disk size. For more information, see Step 1: Resize a disk to extend the capacity of the disk.
Check whether the partition style of the disk whose size you extend needs to be converted into another partition style. For more information about Linux instances, see Determine the procedure of extending the disk. For more information about Windows instance, see Step 1: Check whether the partitions of the disk require to be converted.
Take note that the maximum partition size and number of partitions vary based on the partition type. For more information, see Partition formats.
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.
(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.
NoteIn 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.
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.
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
Convert the data disk from MBR to GPT.
Importantsgdisk
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
NoteIf 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.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
isgpt
, which indicates that the disk is converted to GPT.NoteThe command output varies based on the operating system. If the
Disklabel type
field is not included in the command output, you can check theSystem
field to determine whether the disk is converted to GPT. If the value ofSystem
isGPT
, 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.
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
Issues
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.
Issue: When you run the
sgdisk -g
command to convert a disk on an ECS instance from MBR to GPT, the following message appears: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:
Create a snapshot for the disk to back up data. For more information, see Create a snapshot for a disk.
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.
Run a
rsync
command to copy the data of the original disk to the new disk.Detach and delete the original disk. For more information, see Detach a data disk and Release a disk.
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.