All Products
Search
Document Center

Container Service for Kubernetes:Expand disk volumes for clusters that run a Kubernetes version earlier than 1.16

Last Updated:Mar 26, 2026

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.

Important

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:

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)
Important

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

  1. Verify that the pod is in the Running state.

    kubectl get pod

    Expected output:

    NAME          READY   STATUS    RESTARTS   AGE
    disk-test-0   1/1     Running   0          38s
  2. Get the disk ID and record the current capacity. You will use this as a baseline to confirm the expansion succeeded.

    kubectl get pvc

    The 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

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Storage & Snapshots > Block Storage.

  3. In the top navigation bar, select the region and resource group. 地域

  4. 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).

  5. 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

  1. Verify that the pod is in the Running state.

    kubectl get pod

    Expected output:

    NAME          READY   STATUS    RESTARTS   AGE
    disk-test-0   1/1     Running   0          38s
  2. Get the disk ID and record the current capacity. You will use this as a baseline to confirm the expansion succeeded.

    kubectl get pvc

    The 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
  3. 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=0

    Expected output:

    statefulset.apps/disk-test scaled

Step 2: Expand the disk

After the application is paused, the disk enters the Unattached state.

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Storage & Snapshots > Block Storage.

  3. In the top navigation bar, select the region and resource group. 地域

  4. Find the disk by its ID. Select the disk and click Resize at the bottom of the page.

  5. 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.

Important

Do not manually partition disks used by Kubernetes PVs. Partitioning may corrupt the file system and cause data loss.

  1. Attach the disk to an ECS instance.

    1. On the Block Storage page of the ECS console, find the disk and click Attach in the Actions column.

    2. In the Attach Cloud Disk step, select the target ECS instance and click Next. > Important: Do not select any release options for the disk.

    3. In the Partition Disk and Create and Mount File Systems step, click Configure Later in the Initialization Method section.

    4. Confirm that the disk status changes to In Use.

  2. Connect to the ECS instance. For more information, see Overview of methods for connecting to an ECS instance.

  3. 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/vdb in this example):

    /dev/vdb
  4. Expand the file system.

    resize2fs /dev/vdb

    If the following error appears, run e2fsck -f /dev/vdb first, then re-run resize2fs.

    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.
  5. Verify the file system size.

    1. Mount the disk to a temporary directory. ``bash mkdir /mnt/disk mount /dev/vdb /mnt/disk/ ``

    2. 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 ``

    3. Unmount the disk. ``bash umount /mnt/disk ``

  6. Detach the disk from the ECS instance. For more information, see Detach a data disk.

Step 4: Restart the application

  1. Scale the replicas back to 1 to restart the application.

    kubectl scale sts disk-test --replicas=1

    Expected output:

    statefulset.apps/disk-test scaled
  2. Verify that the pod is running.

    kubectl get pod

    Expected output:

    NAME          READY   STATUS    RESTARTS   AGE
    disk-test-0   1/1     Running   0          5s
  3. 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 /data

    The 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