Symptoms
A cloud disk is formatted with a GPT partition. After a cloud disk extension, using the growpart utility to extend a partition, such as /dev/vdb1, returns an error message similar to the following. As a result, the cloud disk capacity increases, but the available space on the partition and its file system does not increase. This topic uses the /dev/vdb1 partition as an example.
[root@ixxx ~]# growpart /dev/vdb 1
failed [pt_update:1] pt_update /dev/vdb 1
partx: /dev/vdb: error updating partition 1
FAILED: disk=/dev/vdb partition=1: failed to repartition
***** WARNING: Resize failed, attempting to revert ******
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
***** Appears to have gone OK ****
Cause
This issue occurs because the data disk, such as /dev/vdb, lacks the recommended partition alignment. Specifically, the mkpart primary 1 100% command was not run to set the start and end positions of the partition.
You can run the following commands to check whether the partition is aligned:
-
fdisk -l: Check theStartvalue. If the value is not2048, the partition is not aligned. -
parted -l: Check theStartvalue. If the value is not1049 kB, as shown in the following example output, the partition is not aligned.[root@izxxx ~]# parted -l Model: Virtio Block Device (virtblk) Disk /dev/vda: 42.9GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 101MB 99.6MB fat16 EFI System Partition boot 2 101MB 20.1GB 20.0GB ext4 Model: Virtio Block Device (virtblk) Disk /dev/vdb: 3221GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 1074GB 1074GB ext4 primary
Solution
To resolve this issue, you must repartition the disk and then extend the partition. Follow these steps:
-
Connect to the ECS instance remotely.
For more information, see Connection method overview.
-
Run the following command to view the partition information for /dev/vdb1 in the /etc/fstab file.
cat /etc/fstabFor example, the information for the /dev/vdb1 partition is as follows.
[root@iZxxx ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Fri Mar 18 11:23:53 2022 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=1ecad39c-b7f6-4d5f-bfe1-2ffec1877a1d / ext4 defaults 1 1 UUID=B483-4E9C /boot/efi vfat umask=0077,shortname=winnt 0 0 UUID=f315122e-2d1d-4705-aaaa-1ad62ae66096 /mnt ext4 defaults 0 0 -
Run the following command to edit the etc/fstab file, and then manually delete the partition information for /dev/vdb1.
vim /etc/fstab -
Run the following command to unmount the /dev/vdb1 partition.
umount /dev/vdb1[root@xxx ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 31G 0 31G 0% /dev tmpfs 31G 0 31G 0% /dev/shm tmpfs 31G 33M 31G 1% /run tmpfs 31G 0 31G 0% /sys/fs/cgroup /dev/vda2 19G 3.5G 14G 21% / /dev/vda1 95M 12M 84M 12% /boot/efi tmpfs 6.2G 0 6.2G 0% /run/user/0 /dev/vdb1 985G 77M 935G 1% /mnt [root@xxx ~]# umount /dev/vdb1 [root@xxx ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 31G 0 31G 0% /dev tmpfs 31G 0 31G 0% /dev/shm tmpfs 31G 33M 31G 1% /run tmpfs 31G 0 31G 0% /sys/fs/cgroup /dev/vda2 19G 3.5G 14G 21% / /dev/vda1 95M 12M 84M 12% /boot/efi tmpfs 6.2G 0 6.2G 0% /run/user/0 -
Repartition the disk and mount the file system.
ImportantRepartitioning the disk deletes all data on the original partition. Before you proceed, create a snapshot to back up all data on the cloud disk. After you repartition the disk and mount the new file system, you can use the backup data to restore the original data. For more information about how to create a snapshot, see Create a snapshot for a disk.
For more information, see Initialize a data disk on a Linux instance.
-
Extend the partition and file system again. For instructions, see Extend partitions and file systems (Linux).