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.
- 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 of 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.
- Connect to the instance. For more information, see Connect to a Linux instance by using a password or key.
- Run the following command to check the partitions on the disk:
fdisk -lu
The 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
aredos
andgpt
. dos indicates the MBR partition style, and gpt indicates the GPT partition style.Note The values vary based on operating systems. If theDisk label type
parameter is not included in the command output, you can check theSystem
parameter to determine the partition style of the disk. If the value ofSystem
isLinux
, it indicates the MBR partition style. If the value of this parameter isGPT
, it indicates the GPT partition style.
- 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
- If the instance runs Alibaba Cloud Linux 2, Alibaba Cloud Linux 3, or CentOS 6 or later, run the following command:
- 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. - 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:
In the command output shown in the following figure,fdisk -lu /dev/vdb
Disk label type
has a value ofgpt
, which indicates that the disk is converted to GPT.Note The command output varies slightly based on operating systems. If theDisk label type
parameter is not present in the command output, you can check theSystem
parameter to determine whether the disk is converted to GPT. IfSystem
has a value ofGPT
, it indicates that the disk is a GPT disk.
Convert a data disk on a Windows instance from MBR to GPT
Disk 1
are used. Operations may vary based on the image and data disk of your instance. Step 1: Convert the disk from MBR to GPT
- Optional: Back up the data on the disk. 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: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.
- Method 1: Create a snapshot for the disk. Note You are charged for the snapshot. For more information, see Snapshots.
- Create a snapshot for the disk. For more information, see Create a snapshot of a disk.
- 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.
- Method 1: Create a snapshot for the disk.
- Connect to the instance. For more information, see Connect to a Windows instance by using a password or key.
- On the Windows Server desktop, right-click the
icon and select Disk Management.
- Find the data disk that you want to convert from MBR to GPT. In this example, Disk 1 is used.
- Right-click a simple volume and select 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.
- In the Delete simple volume message, click Yes.
- Right-click a blank area next to Disk 1 and select Convert to GPT Disk.
- Right-click the Unallocated section and select New Simple Volume.
- In the New Simple Volume Wizard window, click Next and complete settings as instructed.
Step 2 (Optional): Restore the data on the original disk
FAQ
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.