A cloud disk is an expandable storage device on cloud. After a cloud disk is created, you can expand its capacity at any time to increase its storage capacity without losing any data in it.
After expanding a cloud disk, you need to either assign its expanded capacity to an existing partition, or format it into an independent new partition.
Note:
Extending the file system may affect the existing data. We strongly recommend you to manually create a snapshot to back up your data before the operation.
To protect your existing data, you can choose to use theumount
command to unmount existing partitions and use thefsck
command to check file systems during the operation.
fdisk -l
Note:
MBR partition supports disk with a maximum capacity of 2 TB. When you partition disk with a capacity greater than 2 TB, we recommend that you create and mount a new data disk and use the GPT partition format to copy data. When the GPT partition is used on a Linux CVM, you have to use the parted partition tool, because fdisk will become unavailable.
Partition format | Operations guide | Notes |
---|---|---|
- | Extend the file system | Applicable to scenarios where a file system is created directly on a bare device and no partition is created. |
GPT | Assign the expanded capacity to an existing partition (GPT) | Also applicable to scenarios of direct formatting when no partition is created. |
Format the expanded capacity into an independent new partition (GPT) | The original partition can be retained without changes. | |
MBR | Assign the expanded capacity to an existing partition (MBR) | Also applicable to scenarios of direct formatting when no partition is created. |
Format the expanded capacity into an independent new partition (MBR) | The original partition can be retained without changes. |
resize2fs
command to extend the file system./dev/vdb
as an example, run the following command to extend an EXT file system:resize2fs /dev/vdb
xfs_growfs
command to extend the file system./dev/vdb
as an example, run the following command to extend an XFS file system:xfs_growfs /dev/vdb
df -h
Run the following command as the root user to confirm changes in cloud disk capacity.
parted <Disk path> print
Taking the disk path /dev/vdb
as an example, run the following command:
parted /dev/vdb print
If a message as shown in the following figure appears in the process, enter Fix
.
As shown in the following figure, the cloud disk space is 107 GB after expansion and the existing partition capacity is 10.7 GB.
Run the following command to check whether the cloud disk has partitions mounted:
mount | grep '<Disk path>'
Taking the disk path /dev/vdb
as an example, run the following command:
mount | grep '/dev/vdb'
As shown in the following figure, the cloud disk has one partition (vdb1) mounted to /data
.
Run the following command to unmount the data disk:
umount <Mount point>
Taking the mount point /data
as an example, run the following command:
umount /data
Note:
Unmount the file systems from all partitions on the cloud disk, and perform the operations in Step 4 again. You can run the following command again to confirm that the unmounting is successful:
mount | grep '/dev/vdb'
The file systems are unmounted from all partitions on the cloud disk, as shown in the following figure.
Run the following command to access the parted tool.
parted '<Disk path>'
Taking the disk path /dev/vdb
as an example, run the following command:
parted '/dev/vdb'
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:
Note:
After a partition is deleted and a new one is created, the
Start
value must remain unchanged. Otherwise, data may be lost.
print
This document uses the Start
value 2048s as an example.
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
The following figure shows the command output.
Run the following command to create a new primary partition:
mkpart primary <Start sector of the original partition> 100%
The 100% in the command indicates this partition goes to the end of the disk.
Assume that the primary partition starts from sector 2048 (it must be the same as that of the previously deleted partition, that is, the Start
value must be 2048s), run the following command:
mkpart primary 2048s 100%
If a status as shown in the following figure appears, enter Ignore
.
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.
Run the following command to exit the parted tool:
quit
Run the following command to check the extended partition:
e2fsck -f <Partition path>
Taking the new partition “1” (its partition path is /dev/vdb1
) as an example, run the following command:
e2fsck -f /dev/vdb1
The following figure shows the command output.
Extend your file system as follows:
For an EXT file system:
resize2fs <Partition path>
Taking the partition path /dev/vdb1
as an example, run the following command:plaintext
resize2fs /dev/vdb1
mount <Partition path> <Mount point>
Taking the partition path /dev/vdb1
and the mount point /data
as an example, run the following command:mount /dev/vdb1 /data
For an XFS file system
mount <Partition path> <Mount point>
Taking the partition path /dev/vdb1
and the mount point /data
as an example, run the following command:mount /dev/vdb1 /data
xfs_growfs <Partition path>
Taking the partition path /dev/vdb1
as an example, run the following command:xfs_growfs /dev/vdb1
Run the following command to view the new partition:
df -h
If the result as shown in the following figure is returned, the mounting is successful, and you can see the data disk.
Run the following command as the root user to confirm changes in cloud disk capacity:
parted <Disk path> print
Taking the disk path /dev/vdb
as an example, run the following command:
parted /dev/vdb print
If a message as shown in the following figure appears in the process, enter Fix
.
As shown in the following figure, the cloud disk space is 107 GB after expansion and the existing partition capacity is 10.7 GB.
Run the following command to check whether the cloud disk has partitions mounted:
mount | grep '<Disk path>'
Taking the disk path /dev/vdb
as an example, run the following command:
mount | grep '/dev/vdb'
As shown in the following figure, the cloud disk has one partition (vdb1) mounted to /data
.
Run the following command to unmount the data disk:
umount <Mount point>
Taking the mount point /data
as an example, run the following command:
umount /data
Note:
Unmount the file systems from all partitions on the cloud disk, and perform the operations in Step 4 again. You can run the following command again to confirm that the unmounting operation is successful.
mount | grep '/dev/vdb'
The file systems are unmounted from all partitions on the cloud disk, as shown in the following figure.
Run the following command to access the parted partition tool:
parted '<Disk path>'
Taking the disk path /dev/vdb
as an example, run the following command:
parted '/dev/vdb'
Run the following command to view partitions and record their End
values, which will be used as the start offset of the next partition:
print
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
Taking the End
value 10.7 GB as an example, run the following command:
mkpart primary 10.7GB 100%
Run the following command to check whether the new partition has been created successfully:
print
Run the following command to exit the parted tool:
quit
Run the following command to format this new partition:
mkfs.<fstype> <Partition path>
You can select a file system format such as EXT2 or EXT3.
If you use an EXT3 file system, run the following command:
mkfs.ext3 /dev/vdb2
You can use automatic expansion tools including fdisk, 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 four requirements must be met:
Run the following command as the root user to unmount the partition:
umount <Mount point>
Taking the mount point /data
as an example, run the following command:
umount /data
Run the following command to download an expansion tool.
This tool is recommended in the Chinese mainland:
wget -O /tmp/devresize.py https://tencentcloud.coding.net/p/tencentcloud/d/tencentcloud-cbs-tools/git/raw/master/devresize/devresize.py
This tool is recommended in regions outside the Chinese mainland:
wget -O /tmp/devresize.py https://raw.githubusercontent.com/tencentyun/tencentcloud-cbs-tools/master/devresize/devresize.py
Run the following command to use the tool for expansion:
python /tmp/devresize.py <Disk path>
Taking the disk path /dev/vdb
and the file system vdb1
as an example, run the following command:
python /tmp/devresize.py /dev/vdb
fsck -a <Partition path>
Taking the disk path /dev/vdb
and the file system vdb1
as an example, run the following command:fsck -a /dev/vdb1
b. After the partition is fixed, run the following command again to use the tool for expansion.python /tmp/devresize.py /dev/vdb
Run the following command to manually mount the extended partition:
mount <Partition path> <Mount point>
This document uses the mount point /data
as an example.
/dev/vdb1
exists before the expansion, run the following command:mount /dev/vdb1 /data
mount /dev/vdb /data
Run the following command to view the partition capacity after expansion:
df -h
If the result similar to the following figure is returned, the mount is successful, and you can see the data disk.
Run the following command to view the original partition data after expansion and check whether the file system is added with expanded storage space.
ll /data
df -h
fdisk -l
umount <Mount point>
Taking the mount point /data
as an example, run the following command:umount /data
Note:
Unmount the file systems from all partitions on the cloud disk, and perform the operations in Step 4 again. You can run the following command again to confirm that the unmounting is successful:
mount | grep '<Disk path>'
If the return is null, then all file systems have been unmounted from partitions on the cloud disk.fdisk <Disk path>
Taking the disk path /dev/xvdc
as an example, run the following command:fdisk /dev/xvdc
When prompted, sequentially enter p
(to check existing partitions), n
(to create a partition), p
(to create a primary partition), 2
(to create the second primary partition), press Enter
twice (to use the default configuration), enter w
(to save the partition table), and start the partition, as shown in the following figure:Note:
This document takes creating one partition as an example. You can also create multiple partitions as needed.
5. Run the following command to view the new partition:
fdisk -l
The following figure shows that the new partition xvdc2 has been created.
mkfs.<fstype> <Partition path>
You can select a file system format such as EXT2 or EXT3.mkfs.ext3 /dev/xvdc2
7. Run the following command to create a mount point:
mkdir <New mounting point>
Taking the new mount point /data1
as an example, run the following command:
mkdir /data1
mount <New partition path> <New mount point>
Taking the new partition path /dev/xvdc2
and the new mount point /data1
as an example, run the following command:mount /dev/xvdc2 /data1
df -h
If the result as shown in the following figure is returned, the mounting is successful, and you can see the data disk.Note:
To allow the CVM to automatically mount a data disk upon restart or start, perform Step 10 and Step 11 to add the new partition to
/etc/fstab
.
10. Run the following command to add the partition:
echo '/dev/xvdc2 /data1 ext3 defaults 0 0' >> /etc/fstab
cat /etc/fstab
If the result as shown in the following figure is returned, the partition has been successfully added.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?