If your cluster runs a Kubernetes version earlier than 1.16 or uses basic disks, you cannot expand a disk volume online by updating its persistent volume claim (PVC). Instead, you must manually expand the disk and its file system.
Applicable scope
This topic describes how to expand a disk volume by manually expanding the capacity of the storage medium without modifying the PVC. You can use this method if your cluster runs a Kubernetes version earlier than 1.16 or does not meet the requirements for expanding a disk volume online.
This method requires you to expand the disk in the ECS console. The Kubernetes resource objects in the cluster are not affected. This means the capacity of the PVC and persistent volume (PV) objects in the cluster remains unchanged. To ensure that the PV and PVC objects in the cluster reflect the actual disk capacity, we recommend that you expand a disk volume online.
This method supports online and offline expansion. Select a method as needed.
Online expansion: The application is not paused. However, if the I/O traffic is high during the online expansion of the file system, I/O errors may occur.
Offline expansion: Pausing the application also pauses disk I/O. This ensures data security during the offline expansion of the file system. However, this method requires application downtime.
Basic disks do not support online expansion. Use offline expansion for basic disks.
The following sections use an application with a statically provisioned disk volume as an example to describe how to expand a disk volume.
Online expansion
You can expand a disk online in the ECS console without pausing the application.
Step 1: View disk information
Connect to the cluster. For more information, see Obtain the kubeconfig file of a cluster and use kubectl to connect to the cluster or Use kubectl to connect to a Kubernetes cluster from Workbench or CloudShell.
View information about the pod to which the disk is attached and confirm that the pod is in the Running state.
kubectl get podSample output:
NAME READY STATUS RESTARTS AGE disk-test-0 1/1 Running 0 38sView the PVC to obtain the disk ID.
kubectl get pvcThe sample output shows that the PV bound to the PVC is
d-uf628m33r5rsbi******(the disk ID) and the capacity is 20 GiB.NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE disk-pvc Bound d-uf628m33r5rsbi****** 20Gi RWO disk <unset> 64s
Step 2: Expand the disk and its file system
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group of the resource that you want to manage.
Find the disk to which the application is attached based on the disk ID. Select the disk and click Resize at the bottom of the page.
For more information about how to expand a disk, see Expand a disk (Linux).
In the wizard that appears, follow the on-screen instructions to complete the expansion.
On the Determine Disk and Read Notes page, confirm the disk information, read the notes, and then click I Understand Risks and Have Backed Up Data, Proceed.
On the Configure Resizing Method and New Size page, set the expansion parameters and click OK.
Parameter
Description
Example
New Disk Size
Set the capacity after expansion. The new capacity cannot be smaller than the current capacity.
30 GiB
Resizing Method
Select Online Resizing. After the expansion, you do not need to restart the instance. The new capacity takes effect immediately.
Online Resizing
On the Confirm Resizing Results page, confirm that the disk capacity is expanded, and then click Next Step: Expand Partitions and File Systems.
NoteAfter you expand the disk capacity, you must also expand the file system. Otherwise, the storage space available to the container remains unchanged.
On the Extend Partitions and File Systems page, click Use Cloud Assistant, select Authorize Cloud Assistant to Perform This Operation, and then click Authorize.
After the operation is complete, confirm that both the disk capacity and the file system are expanded.

Offline expansion
Pause the application by setting the number of replicas to 0. After the disk is expanded, you can restart the application.
Step 1: View disk information and pause the application
Connect to the cluster. For more information, see Obtain the kubeconfig file of a cluster and use kubectl to connect to the cluster or Use kubectl to connect to a Kubernetes cluster from Workbench or CloudShell.
View information about the pod to which the disk is attached and confirm that the pod is in the Running state.
kubectl get podSample output:
NAME READY STATUS RESTARTS AGE disk-test-0 1/1 Running 0 38sView the PVC to obtain the disk ID.
kubectl get pvcThe sample output shows that the PV bound to the PVC is
d-uf628m33r5rsbi******(the disk ID) and the capacity is 20 GiB.NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE disk-pvc Bound d-uf628m33r5rsbi****** 20Gi RWO disk <unset> 64sScale the number of replicas for the application to 0 to pause the application.
kubectl scale sts disk-test --replicas=0Expected output:
statefulset.apps/disk-test scaled
Step 2: Expand the disk
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group of the resource that you want to manage.
Find the disk to which the application is attached based on the disk ID. Select the disk and click Resize at the bottom of the page.
In the wizard that appears, follow the on-screen instructions to complete the expansion.
On the Determine Disk and Read Notes page, confirm the disk information, read the notes, and then click I Understand Risks and Have Backed Up Data, Proceed.
On the Configure Resizing Method and New Size page, set the expansion parameters and click OK.
Parameter
Description
Example
New Disk Size
Set the capacity after expansion. The new capacity cannot be smaller than the current capacity.
30 GiB
Resizing Method
After the application is paused, the disk is in the Unattached state. You can select only Offline Resizing.
Offline Resizing
On the Confirm Resizing Results page, confirm that the disk capacity is expanded, and then click Next Step: Extend Partitions and File Systems.
On the Extend Partitions and File Systems page, select Use Documentation and refer to the document in the Extend the partitions and file systems of disks on a Linux instance section.
NoteAfter you expand the disk capacity, you must also expand the file system. Otherwise, the storage space available to the container remains unchanged.
Because the disk is in the Unattached state, you cannot use Cloud Assistant. You must manually expand the file system.
Step 3: Expand the file system
The following operations apply to unpartitioned disks.
We do not recommend that you use partitioned disks in Kubernetes.
If a PV uses an unpartitioned disk, do not manually partition the disk. This may damage the current file system and cause data loss.
If a PV uses a partitioned disk, you must expand the partition device before you expand the file system. For more information, see Expand partitions and file systems (Linux) or Expand partitions and file systems (Windows).
Attach the disk to an ECS instance.
On the Block Storage page of the ECS console, find the target disk and click Attach in the Actions column.
In the Attach Cloud Disk step, select the ECS instance to which you want to attach the disk and click Next.
ImportantDo not select any release options for the disk.
In the Partition Disk and Create and Mount File Systems step, click Configure Later in the Initialization Method section.
Confirm that the status of the disk changes to In Use.
Connect to the ECS instance. For more information, see Overview of methods for connecting to an ECS instance.
Obtain the disk device name.
The following command is a sample. Replace
<serial>with the serial number of the disk.You can quickly find the disk serial number from the disk ID (Disk ID = d-{Disk serial number}). For more information, see View the serial number of a block storage device.
ImportantIf the disk was created before June 10, 2020, the serial number feature is not supported. You cannot run the following command to obtain the disk device name. Instead, you can run the
ls /dev/vd*command before and after you attach the disk and compare the output to identify the device name of the target disk.realpath /dev/disk/by-id/virtio-<serial>The sample output indicates that the disk device name is
/dev/vdb./dev/vdbExpand the file system.
The following command is a sample. Replace the placeholder with the actual disk device name.
resize2fs /dev/vdbIf the following error message is returned, run the
e2fsck -f /dev/vdbcommand as prompted, and then run theresize2fs /dev/vdbcommand to expand the file system.resize2fs 1.46.0 (29-Jan-2020) Please run 'e2fsck -f /dev/vdb' first.After you expand the file system, the following output is expected:
resize2fs 1.46.0 (29-Jan-2020) Resizing the filesystem on /dev/vdb to 7864320 (4k) blocks. The filesystem on /dev/vdb is now 7864320 (4k) blocks long.Confirm that the file system is expanded.
Create a temporary folder named
/mnt/disk/and mount the disk to the temporary folder.mkdir /mnt/disk mount /dev/vdb /mnt/disk/Check the size of the file system.
df /mnt/disk/The expected output shows that the capacity of
/dev/vdbis expanded to 30 GiB.Filesystem 1K-blocks Used Available Use% Mounted on /dev/vdb 30787536 24 30771128 1% /mnt/diskUnmount the disk from the temporary folder.
umount /mnt/disk
Detach the disk from the ECS instance. For more information, see Detach a data disk.
Step 4: Restart the application
Scale the number of replicas for the application to 1 to restart the application.
kubectl scale sts disk-test --replicas=1Expected output:
statefulset.apps/disk-test scaledCheck whether the pod is restored.
kubectl get podExpected output:
NAME READY STATUS RESTARTS AGE disk-test-0 1/1 Running 0 5sCheck the size of the file system.
kubectl exec -it disk-test-0 -- df /dataThe expected output shows that the file system corresponding to the mount path is expanded.
Filesystem 1K-blocks Used Available Use% Mounted on /dev/vdb 30787536 24 30771128 1% /data