The Master Boot Record (MBR) partition format does not support disks larger than 2 TiB. If your disk uses the MBR partition format and you want to resize it to be larger than 2 TiB, you must first convert the partition format from MBR to GPT. After the conversion, you can resize the partition and file system.
Preparations
You have completed Step 1: Resize a disk.
Different partition types support different maximum partition capacities and numbers of partitions. For more information, see Overview of data disk initialization.
Procedure
(Optional) Create a snapshot of the disk to back up your data.
NoteData is not typically lost during the conversion. However, we recommend that you back up your data in advance to prevent data loss that may be caused by incorrect operations.
Run the following command to install the gdisk tool.
For Alibaba Cloud Linux 2/3, CentOS 7, and later versions, run the following command.
type sgdisk || sudo yum install -y gdiskFor Debian 11, Ubuntu 14, and later versions, run the following command.
type sgdisk || sudo apt-get install -y gdisk
Run the following command to convert the partition format from MBR to GPT.
WarningThe
sgdiskcommand can be used only for disks, such as/dev/nvme2n1. It cannot be used for partitions, such as/dev/nvme2n1p1. Otherwise, the file system may be corrupted.In this example, the disk is /dev/nvme2n1. Replace
/dev/nvme2n1with the actual device name of your disk.sudo sgdisk -g /dev/nvme2n1In the command,
-gconverts the MBR partition to a GPT partition and retains the original MBR backup.If the message
successfullyis returned, the conversion is successful.NoteIf an error is reported when you run the
sgdiskcommand, see the FAQ section for troubleshooting information.Run the following command to verify the partition conversion.
In this example, the disk name is
/dev/nvme2n1. Replace this with your actual disk name.sudo fdisk -lu /dev/nvme2n1If
Disklabel typeis set togpt, the partition is converted to the GPT format.
What to do next
Resize the partition and file system
FAQ
Problem: The following message is returned when you run the
sgdisk -gcommand to convert a partition.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: The remaining space at the end of the disk is less than 33 sectors. This means there is not enough space to convert the MBR partition to a GPT partition.
Solution: First, resize the disk, and then convert the partition format.
Problem: The following message is returned when you run the
sgdisk -gcommand to convert a partition.Warning! Main partition table overlaps the first partition by 24 blocks! Try reducing the partition table size by 96 entries. (Use the 's' item on the experts' menu.) Warning! Main partition table overlaps the first partition by 24 blocks! Try reducing the partition table size by 96 entries. (Use the 's' item on the experts' menu.) Aborting write of new partition table.Cause: The remaining space at the beginning of the disk is insufficient for the header required by the GPT partition table. This issue usually occurs because data or a partition is located at the very beginning of the disk, leaving no space for the GPT partition table structure. In this case, partition conversion is not supported.
Solution:
Create a snapshot of the disk.
Run the
rsynccommand to copy data from the old disk to the new disk.
Problem: The following message is returned when you run the
type sgdisk || sudo yum install -y gdiskcommand.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 kCause: The download folder (`/var/cache/yum/x86_64/2.1903/updates/packages`) does not have enough space to download the required package.
Solution: You must clear space to increase the available storage in the download folder.