If your cloud disk has a GPT partition that contains the file system, you can use either of the following methods to extend partitions and file systems:
You can use automatic expansion tools including e2fsck and resize2fs to add the expanded cloud disk capacity to the existing file system on a Linux CVM. To ensure a successful expansion, the following requirements must be met:
parted <Disk path> print
Taking the disk path /dev/vdc
as an example, run the following command:
parted /dev/vdc print
If a message as shown in the following figure appears in the process, enter Fix
.
The cloud disk size is 2,040 GB after expansion and the existing partition capacity is 10.7 GB, as shown in the following figure:
2. Run the following command to check whether the cloud disk has partitions mounted.
mount | grep '<Disk path>'
Taking the disk path /dev/vdc
as an example, run the following command:
mount | grep '/dev/vdc'
/data
.umount <Mount point>
Taking the mount point /data
as an example, run the following command:
umount /data
parted '<Disk path>'
Taking the disk path /dev/vdc
as an example, run the following command:
parted '/dev/vdc'
Run the following command to change the unit from the default “GB” to “sector” for display and operation.
unit s
Run the following command to view partitions and record their Start
values.
print
Note:Do record
Start
values. After a partition is deleted and a new one is created, theStart
value must remain unchanged. Otherwise, data may be lost.
6. Run the following command to delete the existing partition.
rm <Partition Number>
For example, run the following command to delete the partition “1” from the cloud disk.
rm 1
print
Note:You can immediately run the
rescue
command, and enterStart
andEnd
values as prompted to restore a partition being accidentally deleted.
mkpart primary <Start sector of the original partition> 100%
The 100% in the command indicates this partition goes to the end of the disk. Enter the Start
value obtained in step 5. In this document, the start sector of the original partition is 2048s (that is, the Start
value is 2048s), run the following command:
mkpart primary 2048s 100%
If a status appears as shown in the following figure, enter Ignore
.
9. Run the following command to check whether the new partition has been created successfully.
print
If the result as shown in the following figure is returned, the new partition has been created successfully.
10. Run the following command to close the parted tool.
quit
e2fsck -f <Partition path>
Taking the new partition “1” (its partition path is /dev/vdc1
) as an example, run the following command:
e2fsck -f /dev/vdc1
The following figure shows the command output.
12. Use a file system-specific command to resize each file system on the new partition.
resize2fs <Partition path>
Taking the partition path /dev/vdc1
as an example, run the following command:
resize2fs /dev/vdc1
If the result as shown in the following figure is returned, the expansion is successful.
xfs_growfs <Partition path>
Taking the partition path /dev/vdc1
as an example, run the following command:
xfs_growfs /dev/vdc1
mount <Partition path> <Mount point>
Taking the partition path /dev/vdc1
and the mount point /data
as an example, run the following command:
mount /dev/vdc1 /data
df -h
If the result as shown in the following figure is returned, the mounting is successful, and you can see the data disk.
parted <Disk path> print
Taking the disk path /dev/vdc
as an example, run the following command:
parted /dev/vdc print
If a message as shown in the following figure appears in the process, enter Fix
.
The cloud disk size is 2,147 GB after expansion and the existing partition capacity is 2,040 GB, as shown in the following figure.
2. Run the following command to check whether the cloud disk has partitions mounted.
mount | grep '<Disk path>'
Taking the disk path /dev/vdc
as an example, run the following command:
mount | grep '/dev/vdc'
/data
.umount <Mount point>
Taking the mount point /data
as an example, run the following command:
umount /data
parted '<Disk path>'
Taking the disk path /dev/vdc
as an example, run the following command:
parted '/dev/vdc'
End
values, which will be used as the start offset of the next partition.print
5. Run the following command to create a primary partition. This partition starts at the end of existing partitions, and covers all the new space on the disk.
mkpart primary start end
Obtain the End
value in step 4. In this example, the End
value is 2,040 GB, run the following command:
mkpart primary 2040GB 100%
print
If the following output is returned, the partition has been created.
7. Run the following command to close the parted tool.
quit
mkfs.<fstype> <Partition path>
Taking EXT4 as an example, run the following command:
mkfs.ext4 /dev/vdc2
mount <Partition path> <Mount point>
Taking the partition path /dev/vdc2
and the mount point /data
as an example, run the following command:
mount /dev/vdc2 /data
df -h
If the result as shown in the following figure is returned, the mounting is successful, and you can see the data disk.
Extending Partitions and File Systems (Windows)
If you encounter a problem when using Tencent Cloud CBS, refer to the following documents for troubleshooting as needed:
Was this page helpful?