Overview
Expanding a data disk via the console only increases its storage space. You need to extend the partition or file system of the cloud disk to the larger size. This document describes how to extend partitions and file systems online.
Prerequisite
Before extending partition or file system, create a snapshot of the cloud disk to back up data. For more information, see Creating Snapshots.
This practice helps you roll back snapshot to recover data in case of data loss due to maloperation. The Linux CVM kernel should be version 3.6.0 or later. You can use the uname -a
command to check the kernel version.
If the kernel version is earlier than 3.6.0, see Determining the Expansion Method. Operating Environment
|
Operating system | CentOS 8.0 64-bit |
Cloud disk (data disk) | /dev/vdb : Uses the MBR partition and the EXT4 file system, and expands from 50 GB to 60 GB via the console.
/dev/vdc : Uses the GPT partition and the XFS file system, and expands from 50 GB to 60 GB via the console.
|
Directions
Viewing partitions of the cloud disk
2. Run the following command to query partitions of the cloud disk.
The following information appears:
As shown in the figure, The 60 GB /dev/vdb
data disk contains a 50 GB MBR partition /dev/vdb1
.
The 60 GB /dev/vdc
data disk contains a 50 GB GPT partition /dev/vdc1
.
3. Run the following command to determine the file system type of existing partitions.
The following information appears:
As shown in the figure, The /dev/vdb1
partition is on an EXT4 file system that has been attached to /mnt/disk1
.
The /dev/vdc1
partition is on an XFS file system that has been attached to /mnt/disk2
.
Extending a partition
1. Use the command as needed to install the gdisk tool.
For a MBR partition, skip this step.
For a GPT partition, run the following command according to the operating system of the CVM.
2. Run the following command to install the growpart tool according to the operating system of the CVM.
yum install -y cloud-utils-growpart
apt-get install -y cloud-guest-utils
3. Run the following command to extend partitions using growpart.
Take extending the /dev/vdb1
partition as an example. Note that there is a space between /dev/vdb
and 1
in the command. Replace with your actual values.
If information similar to what is shown below is returned, the partition has been extended.
Extending a file system
1. Use the file system-specific command to resize a file system based on the type obtained in step 3. Extending an EXT file system
Extending an XFS file system
Run the following command to extend the EXT file system.
The following information will appear:
Run the following command to extend the XFS file system.
Take mounting the /dev/vdc1
file system to`/mnt/disk2` as an example, then run the following command:
The following information will appear:
2. Run the following command to view the result.
If information similar to what is shown below is returned, the file system has been extended.
3. Check data integrity and CVM running status after expansion.
You can roll back the snapshot to recover data in case of exceptions. For more information, see Rolling Back Snapshots.
Was this page helpful?