If your cluster runs Kubernetes earlier than version 1.16, or uses basic disks, you cannot expand a disk volume by updating its persistent volume claim (PVC). Instead, expand the underlying disk and its file system directly in the ECS console, without modifying any Kubernetes objects.
This method does not update the PVC or persistent volume (PV) capacity in Kubernetes. After expansion, kubectl get pvc still reports the original size. To keep PVC and PV objects in sync with the actual disk capacity, use online disk volume expansion when your cluster meets its requirements.
The following sections use a statically provisioned disk volume as an example.
Prerequisites
Before you begin, make sure that you have:
-
Access to the cluster via kubectl. 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.
-
Access to the ECS console with permission to resize disks.
-
A backup of critical data on the disk.
Choose a method
Two methods are available. Which one to use depends on whether your disk supports online resizing and whether you can tolerate application downtime.
| Method | Application state | Data safety | Use when |
|---|---|---|---|
| Online expansion | Running (no downtime) | High I/O during file system resize may cause I/O errors | Your disk supports online resizing |
| Offline expansion | Paused (downtime required) | Disk I/O stops with the app, ensuring data safety | Your disk uses basic disk type (basic disks do not support online expansion) |
Basic disks do not support online expansion. Use offline expansion for basic disks.
Online expansion
Expand the disk and its file system without pausing the application.
Step 1: Get the disk ID and record the current size
-
Verify that the pod is in the Running state.
kubectl get podExpected output:
NAME READY STATUS RESTARTS AGE disk-test-0 1/1 Running 0 38s -
Get the disk ID and record the current capacity. You will use this as a baseline to confirm the expansion succeeded.
kubectl get pvcThe output shows the PV name (which is the disk ID) and the current capacity. In this example, the disk ID is
d-uf628m33r5rsbi******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 Storage & Snapshots > Block Storage.
-
In the top navigation bar, select the region and resource group.

-
Find the disk by its ID. Select the disk and click Resize at the bottom of the page. > For more information, see Expand a disk (Linux).
-
Complete the wizard:
-
On the Determine Disk and Read Notes page, confirm the disk information and click I Understand Risks and Have Backed Up Data, Proceed.
-
On the Configure Resizing Method and New Size page, set the parameters and click OK.
Parameter
Description
Example
New Disk Size
The capacity after expansion. Cannot be smaller than the current capacity.
30 GiB
Resizing Method
Select Online Resizing. The new capacity takes effect immediately without an instance restart.
Online Resizing
-
On the Confirm Resizing Results page, confirm the new capacity and click Next Step: Expand Partitions and File Systems. > Important: After expanding 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 completes, both the disk capacity and the file system are expanded.

-
Step 3: Verify the expansion
Confirm the file system is expanded inside the container.
kubectl exec -it disk-test-0 -- df /data
The output should show the new capacity (30 GiB in this example):
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vdb 30787536 24 30771128 1% /data
Offline expansion
Pause the application, expand the disk and its file system, then restart the application.
Step 1: Get the disk ID and pause the application
-
Verify that the pod is in the Running state.
kubectl get podExpected output:
NAME READY STATUS RESTARTS AGE disk-test-0 1/1 Running 0 38s -
Get the disk ID and record the current capacity. You will use this as a baseline to confirm the expansion succeeded.
kubectl get pvcThe output shows the disk ID and current capacity. In this example, the disk ID is
d-uf628m33r5rsbi******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 -
Scale the StatefulSet replicas to 0 to pause the application. This also pauses disk I/O, ensuring data safety during file system expansion.
kubectl scale sts disk-test --replicas=0Expected output:
statefulset.apps/disk-test scaled
Step 2: Expand the disk
After the application is paused, the disk enters the Unattached state.
-
Log on to the ECS console.
-
In the left-side navigation pane, choose Storage & Snapshots > Block Storage.
-
In the top navigation bar, select the region and resource group.

-
Find the disk by its ID. Select the disk and click Resize at the bottom of the page.
-
Complete the wizard:
-
On the Determine Disk and Read Notes page, confirm the disk information and click I Understand Risks and Have Backed Up Data, Proceed.
-
On the Configure Resizing Method and New Size page, set the parameters and click OK.
Parameter
Description
Example
New Disk Size
The capacity after expansion. Cannot be smaller than the current capacity.
30 GiB
Resizing Method
Because the disk is in the Unattached state, only Offline Resizing is available.
Offline Resizing
-
On the Confirm Resizing Results page, confirm the new capacity and click Next Step: Extend Partitions and File Systems.
-
On the Extend Partitions and File Systems page, select Use Documentation and follow the Extend the partitions and file systems of disks on a Linux instance section. > Note: > - After 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, Cloud Assistant is not available. Expand the file system manually in the next step.
-
Step 3: Expand the file system
The following steps apply to unpartitioned disks.
Do not manually partition disks used by Kubernetes PVs. Partitioning may corrupt the file system and cause data loss.
-
If the PV uses an unpartitioned disk, do not partition it.
-
If the PV uses a partitioned disk, expand the partition device before expanding 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 disk and click Attach in the Actions column.
-
In the Attach Cloud Disk step, select the target ECS instance and click Next. > Important: Do 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 disk status changes to In Use.
-
-
Connect to the ECS instance. For more information, see Overview of methods for connecting to an ECS instance.
-
Get the disk device name. The disk ID follows the format
d-{serial number}. Use the serial number to find the device name. For more information, see View the serial number of a block storage device.If the disk was created before June 10, 2020, the serial number feature is not supported. Instead, run
ls /dev/vd*before and after attaching the disk, and compare the output to identify the new device name.realpath /dev/disk/by-id/virtio-<serial>Expected output (the device name is
/dev/vdbin this example):/dev/vdb -
Expand the file system.
resize2fs /dev/vdbIf the following error appears, run
e2fsck -f /dev/vdbfirst, then re-runresize2fs.resize2fs 1.46.0 (29-Jan-2020) Please run 'e2fsck -f /dev/vdb' first.After a successful expansion:
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. -
Verify the file system size.
-
Mount the disk to a temporary directory. ``
bash mkdir /mnt/disk mount /dev/vdb /mnt/disk/`` -
Check the file system size. ``
bash df /mnt/disk/`The output should show the expanded capacity (30 GiB in this example):`bash Filesystem 1K-blocks Used Available Use% Mounted on /dev/vdb 30787536 24 30771128 1% /mnt/disk`` -
Unmount the disk. ``
bash 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 replicas back to 1 to restart the application.
kubectl scale sts disk-test --replicas=1Expected output:
statefulset.apps/disk-test scaled -
Verify that the pod is running.
kubectl get podExpected output:
NAME READY STATUS RESTARTS AGE disk-test-0 1/1 Running 0 5s -
Verify the expanded file system inside the container. Compare this output against the baseline recorded in Step 1 to confirm the expansion succeeded.
kubectl exec -it disk-test-0 -- df /dataThe output confirms the file system at the mount path is expanded:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/vdb 30787536 24 30771128 1% /data
What's next
-
To expand disk volumes in clusters running Kubernetes 1.16 or later, see Expand a disk volume online.
-
To use a statically provisioned disk volume, see Statically provisioned disk volumes.