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.
(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.
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:
sudo fdisk -lu
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
isdos
, the MBR partition style is used. If the value isgpt
, the GPT partition style is used.NoteThe command output varies based on the operating system. If the
Disklabel type
field is not displayed, check theSystem
field to determine the partition style. If the value ofSystem
isLinux
, the MBR partition style is used. If the value isGPT
, 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.
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.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.
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.
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
(Optional) Back up the data on the disk.
WarningWhen 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.
NoteYou are charged for the snapshot. For more information, see Billing of snapshots.
Create a snapshot for the disk. For more information, see Create a snapshot.
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.
Connect to the instance.
For more information, see Connect to a Windows instance by using a password or key.
On the Windows 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.
ImportantIf 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.
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 prompted.
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.
In the Assign Drive Letter or Path step, select Assign the following drive letter, select a drive letter (example: D), and then click Next.
In the Format Partition step, select Format this volume with the following settings, configure formatting settings, and then click Next.
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.
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
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.
Problem: 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.