Last updated:2021-09-22 20:41:57
You have expanded the capacity of an EBS volume that uses GPT partitioning and has file systems. The capacity of the EBS volume after the expansion is greater than or equal to 2 TB. You can resize the partitions and file systems on the EBS volume by using one of the following methods as needed:
Operating environment
Resource | Description |
---|---|
Operating system | CentOS 6.5 64-bit |
Data disk | /dev/vdb: uses GPT partitioning and ext4 file systems. The capacity of the disk has been expanded from 200 GB to 2,200 GB. /dev/vdc: uses GPT partitioning and xfs file systems. The capacity of the disk has been expanded from 2,400 GB to 3,000 GB. |
lsblk
command to view the information about the partitions and mount points on the data disks attached to your KEC instance. In this example, the data disks are /dev/vdb
and /dev/vdc
.lsblk
The following figure shows the output.
The following table describes the information extracted from the figure.
Data disk | Partition | Partition description |
---|---|---|
/dev/vdb is the data disk with a capacity of 2,200 GB. | /dev/vdb1 | The capacity of the partition is 200 GB. The mount point is /mnt/data_disk01. |
/dev/vdc is the data disk with a capacity of 3,000 GB. | /dev/vdc1 | The capacity of the partition is 2.4 TB. The mount point is /mnt/data_disk02. |
df -Th
The following figure shows the output.
The following table describes the information extracted from the figure.
Partition | File system type | Mount point |
---|---|---|
/dev/vda1 | ext4 | Mounted to / |
/dev/vdb1 | ext4 | Mounted to /mnt/data_disk01 |
/dev/vdc1 | xfs | Mounted to /mnt/data_disk02 |
Run the umount <Mount point>
command to unmount partitions. In this example, unmount the /dev/vdb1
partition from the /mnt/data_disk01
mount point.
umount /mnt/data_disk01
Note: Before you proceed to the next step, make sure that you have unmounted all the partitions of the data disks for which you want to allocate the expanded capacity.
Run the parted <Data disk name> print
command to view the information about the GPT partitions on a data disk. Record the partition number and start sector value of each existing partition. In this example, view the information about the GPT partitions on the /dev/vdb/
data disk.
parted /dev/vdb print
If the Fix/Ignore/Cancel
and Fix/Ignore
messages appear, as shown in the following figure, enter Fix
.
The following figure shows the output.
In this example, the capacity of the existing partition is 200 GB. The partition number is 1. The start sector value is 1049kB.
Note: You must record the start sector value of the existing partition. After you delete the existing partition, you must use the same start sector value to create a partition. Otherwise, data loss occurs.
Run the parted <Data disk name>
command to partition a data disk by using the parted partition utility. In this example, allocate the expanded capacity of the /dev/vdb
data disk, which is 2,000 GB, to the existing GPT partition on the data disk.
parted /dev/vdb
Perform the following steps:
a. Run the rm <Partition number>
command to delete the existing partition. In this example, the /dev/vdb
data disk has only one partition and the partition number is 1. Therefore, run the following command:
rm 1
b. Run the print
command to make sure that the partition is deleted.
Note: If you accidentally delete a partition, run the rescue command and enter the start and end values as prompted to recover the partition.
c. Run the mkpart primary <Start sector value of the existing partition> 100%
command to create a primary partition.
In this example, the start sector value of the existing partition on the /dev/vdb
data disk is 1049kB
. 100% indicates that this partition ends at the end of the data disk. To allocate all the expanded capacity of the data disk to this partition, run the following command:
mkpart primary 1049kB 100%
d. Run the print
command to check whether the partition is created.
e. Run the quit
command to exit the parted utility.
The following figure shows the output.
In the operating system of your KEC instance, resize a file system by running one of the following commands based on the type of the file system.
e2fsck -f /dev/vdb1
Resize the file system of the /dev/vdb1 partition on the /dev/vdb data diskresize2fs /dev/vdb1
The following figure shows the output.Note: In the preceding commands,
/dev/vdb1
is the partition name. You must change it based on your business requirements.
mount /dev/vdc1 /mnt/data_disk02
Resize the file system of the /dev/vdc1 partition on the /dev/vdc data diskxfs_growfs /mnt/data_disk02
The following figure shows the output.Note: In the preceding commands,
/mnt/data_disk02
is the mount point of the/dev/vdc1
partition. You must change it based on your business requirements.
Run the mount <Partition name> <Mount point>
command to manually mount the resized partitions. In this example, mount the /dev/vdb1
partition to the mnt/data_disk01
mount point.
mount /dev/vdb1 /mnt/data_disk01
Run the following command to check the resizing results:
df -Th
The following figure shows the output.
The figure shows that the resizing succeeded. When you check the results, compare the results with the original capacities.
Operating environment
Resource | Description |
---|---|
Operating system | CentOS 6.5 64-bit |
Data disk | /dev/vdb: uses GPT partitioning and ext4 file systems. Keep the capacity of Partition 1, which is 200 GB, unchanged and create Partition 2 with a capacity of 2,000 GB. /dev/vdc: uses GPT partitioning and xfs file systems. Keep the capacity of Partition 1, which is 2,400 GB, unchanged and create Partition 2 with a capacity of 600 GB. |
lsblk
command to view the information about the partitions and mount points on the data disks attached to your KEC instance. In this example, the data disks are /dev/vdb
and /dev/vdc
.lsblk
The following figure shows the output.
The following table describes the information extracted from the figure.
Data disk | Partition | Partition description |
---|---|---|
/dev/vdb is the data disk with a capacity of 2,200 GB. | /dev/vdb1 | The capacity of the partition is 200 GB. The mount point is /mnt/data_disk01. |
/dev/vdc is the data disk with a capacity of 3,000 GB. | /dev/vdc1 | The capacity of the partition is 2.4 TB. The mount point is /mnt/data_disk02. |
df -Th
The following figure shows the output.
The following table describes the information extracted from the figure.
Partition | File system type | Mount point |
---|---|---|
/dev/vda1 | ext4 | Mounted to / |
/dev/vdb1 | ext4 | Mounted to /mnt/data_disk01 |
/dev/vdc1 | xfs | Mounted to /mnt/data_disk02 |
Run the umount <Mount point>
command to unmount partitions. In this example, unmount the /dev/vdb1
partition from the /mnt/data_disk01
mount point.
umount /mnt/data_disk01
Note: Before you proceed to the next step, make sure that you have unmounted all the partitions of the data disks for which you want to allocate the expanded capacity.
Run the parted <Data disk name> print
command to view the information about the GPT partitions on a data disk. Record the partition number and end sector value of each existing partition. In this example, view the information about the GPT partitions on the /dev/vdb/
data disk.
parted /dev/vdb print
If the Fix/Ignore/Cancel
and Fix/Ignore
messages appear, as shown in the following figure, enter Fix
.
The following figure shows the output.
In this example, the capacity of the existing partition is 200 GB. The partition number is 1. The end sector value is 215GB.
Note: You must record the end sector value of the existing partition. The value is used as the start offset of the partition to be created.
Run the parted <Data disk name>
command to partition a data disk by using the parted partition utility. In this example, allocate the expanded capacity of the /dev/vdb
data disk, which is 2,000 GB, to a newly created and formatted GPT partition.
parted /dev/vdb
Perform the following steps:
a. Run the print
command to view the partition number and end sector value of the existing partition.
b. Run the mkpart <Partition name> <Start sector value> 100%
command to create a primary partition. This partition starts from the end of the existing partition and is allocated all the expanded capacity of the data disk.
In this example, the name of the new /dev/vdb2
partition is primary````. The start sector value of this partition is equal to the end sector value of the existing partition, which is
215GB```. To allocate all the expanded capacity of the data disk to the new partition, run the following command:
mkpart primary 215GB 100%
c. Run the print
command to check whether the partition is created.
d. Run the quit
command to exit the parted utility.
The following figure shows the output.
Run the following command to view the new partition:
lsblk
The following figure shows the output. In this example, a partition is also created for the /dev/vdc
data disk by following Step 5.
Run the mkfs.<fstype> <Partition name>
command to format the new partitions and create file systems.
To create an ext* file system, for example, ext4, run the following command:
Create an ext4 file system for the /dev/vdb2 partition on the /dev/vdb2 data disk
mkfs.ext4 /dev/vdb2
The following figure shows the output.
Note: In the preceding command,
/dev/vdb2
is the partition name. You must change it based on your business requirements.
To create an xfs file system, run the following command:
Create an xfs file system for the /dev/vdc2 partition on the /dev/vdc data disk
mkfs.xfs -f /dev/vdc2
The following figure shows the output.
Note: In the preceding command,
/dev/vdc2
is the partition name. You must change it based on your business requirements.
If the message-bash: mkfs.xfs: command not found
appears, run theyum -y install xfsprogs
command to install the RPM package of xfsprogs.
Run the mkdir <New mount point>
command to create a mount point for each new partition. In this example, create the /mnt/data_disk03
mount point.
mkdir /mnt/data_disk03
Run the mount <Partition name> <Mount point>
command to manually mount the new partitions. In this example, mount the /dev/vdb2
partition to the /mnt/data_disk03
mount point.
mount /dev/vdb2 /mnt/data_disk03
Run the following command to view the information about the new partitions:
df -Th
The following figure shows the output.
The figure shows that the resizing succeeded. When you check the results, compare the results with the original capacities.
Description of optional actions
If you want the new partitions of the data disks to be automatically mounted to the KEC instance when the KEC instance starts or restarts, perform the following steps to add the information about the new partitions to the /etc/fstab file.
/dev/vdb2
partition to the /mnt/data_disk03
mount point.echo '/dev/vdb2 /mnt/data_disk03 ext4 defaults 0 0' >> /etc/fstab
cat /etc/fstab
command to view the auto-mount configuration.cat /etc/fstab
The following figure shows the output.Did you find the above information helpful?
Please give us your feedback.
Thank you for your feedback.