All Products
Search
Document Center

Container Service for Kubernetes:Manually expand a disk volume

Last Updated:Mar 26, 2026

Use this procedure when your cluster runs Kubernetes earlier than 1.16, or when the disk is a basic disk. In these cases, you cannot expand a disk volume by editing the persistent volume claim (PVC). Instead, resize the disk on the Elastic Compute Service (ECS) side and extend the file system manually.

Important

This method does not modify the PVC or persistent volume (PV). After resizing, the capacity values displayed in the PVC and PV remain unchanged even though the actual disk is larger. For clusters that support it, use online disk volume expansion instead, which keeps the PVC and PV in sync automatically.

The examples in this topic use an application backed by a dynamically provisioned disk volume.

Choose a resizing method

MethodDowntime requiredWhen to use
Online resizingNoYou cannot afford application downtime. Note that if disk I/O throughput is high during file system expansion, an I/O error may occur.
Offline resizingYesData integrity is the priority, or the disk is in Pending state after the application pauses.
Important

Basic disks cannot be resized without downtime. Use offline resizing for basic disks.

Online resizing

Prerequisites

Before you begin, make sure that you have:

Step 1: Record the current state

Before resizing, record the current disk capacity so you can verify the change later.

  1. Confirm 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 current capacity from the PVC.

    kubectl get pvc

    Expected output:

    NAME       STATUS   VOLUME                   CAPACITY   ACCESS MODES   STORAGECLASS   VOLUMEATTRIBUTESCLASS   AGE
    disk-pvc   Bound    d-uf628m33r5rsbi******   20Gi       RWO            disk           <unset>                 64s

    Note the current capacity (20 GiB) and the disk ID shown in the VOLUME column (d-uf628m33r5rsbi******).

Step 2: Resize the disk on the ECS side

  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 it, and click Resize at the bottom of the page.

  5. Complete the resize wizard:

    • Determine disk and read notes: Confirm the disk information and click I Understand Risk and Have Backed Up Data. Proceed.

    • Configure resizing method and new size: Set the parameters and click OK.

      ParameterDescriptionExample
      New disk sizeNew capacity. The value cannot be less than the current disk size.30 GiB
      Resizing methodSelect Online Resizing. The new size takes effect immediately without restarting the instance.Online resizing
    • Confirm resizing results: Confirm the disk is resized and click Next Step, Extend Partitions and File Systems. > Note: After the disk is resized, extend the file system to make the new capacity available to the application.

    • Extend partitions and file systems: Select Use Cloud Assistant, check Authorize Cloud Assistant to Perform This Operation, and click Authorize Cloud Assistant. After Cloud Assistant completes, confirm that both the disk and file system are at the new size. 云盘扩容

Step 3: Verify the expansion

Check the file system size inside the pod to confirm the expansion is complete.

kubectl exec -it disk-test-0 -- df /data

The output should show the updated capacity (30 GiB):

Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/vdb        30787536    24  30771128   1% /data

If the capacity still shows the old value, wait a few minutes and retry. The file system expansion may take a short time to propagate.

Offline resizing

Offline resizing pauses the application by scaling replicas to 0, resizes the disk, extends the file system manually, and then restarts the application.

Prerequisites

Before you begin, make sure that you have:

Step 1: Record the disk ID and pause the application

  1. Confirm 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 from the PVC.

    kubectl get pvc

    Expected output:

    NAME       STATUS   VOLUME                   CAPACITY   ACCESS MODES   STORAGECLASS   VOLUMEATTRIBUTESCLASS   AGE
    disk-pvc   Bound    d-uf628m33r5rsbi******   20Gi       RWO            disk           <unset>                 64s
  3. Scale the StatefulSet to 0 replicas to pause the application and release the disk.

    kubectl scale sts disk-test --replicas=0

    Expected output:

    statefulset.apps/disk-test scaled

Step 2: Resize the disk on the ECS side

  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 it, and click Resize at the bottom of the page.

  5. Complete the resize wizard:

    • Determine disk and read notes: Confirm the disk information and click I Understand Risk and Have Backed Up Data. Proceed.

    • Configure resizing method and new size: Set the parameters and click OK.

      ParameterDescriptionExample
      New disk sizeNew capacity. The value cannot be less than the current disk size.30 GiB
      Resizing methodBecause the application is paused, the disk is in Pending state. In this case, you can select only Offline Resizing.Offline resizing
    • Confirm resizing results: Confirm the disk is resized and click Next Step, Extend Partitions and File Systems.

    • Extend partitions and file systems: Select Use Documentation and follow the steps in the Extend Partitions and File Systems (Linux) section. > Note: Use Cloud Assistant is unavailable when the disk is in Pending state. Extend the file system manually in the next step.

Step 3: Extend the file system

The following steps apply to unpartitioned disks.

Important

Do not use partitioned disks in Kubernetes.

  1. Attach the disk to an ECS instance.

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

    2. On the Attach Cloud Disk page, select the target ECS instance and click Next. > Important: Do not select any disk-related release behavior.

    3. On the Partition Disk and Create and Mount File Systems page, 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 instructions, see Methods for connecting to an ECS instance.

  3. Get the device identifier of the disk. Use the disk serial number to identify the device. The disk ID maps to the serial number as: disk ID = d-{serial number}. For more information, see Query the serial numbers of block storage devices. Replace <serial> with the actual serial number:

    Important

    Disks created before June 10, 2020 do not support the serial number feature. To identify the device, run ls /dev/vd* before and after attaching the disk, then compare the output to find the new device.

    realpath /dev/disk/by-id/virtio-<serial>

    Expected output (the device identifier):

    /dev/vdb
  4. Extend the file system. Replace /dev/vdb with your actual device identifier.

    resize2fs /dev/vdb

    If the command returns the following error, run e2fsck first, then retry resize2fs:

    resize2fs 1.46.0 (29-Jan-2020)
    Please run 'e2fsck -f /dev/vdb' first.
    e2fsck -f /dev/vdb
    resize2fs /dev/vdb

    A successful resize produces output similar to:

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

      mkdir /mnt/disk
      mount /dev/vdb /mnt/disk/
    2. Check the capacity.

      df /mnt/disk/

      The output confirms the disk is now 30 GiB.

      Filesystem     1K-blocks  Used Available Use% Mounted on
      /dev/vdb        30787536    24  30771128   1% /mnt/disk
    3. Unmount the disk.

      umount /mnt/disk
  6. Detach the disk from the ECS instance. For instructions, see Detach a data disk.

Step 4: Restart the application

  1. Scale the StatefulSet back to one replica.

    kubectl scale sts disk-test --replicas=1

    Expected output:

    statefulset.apps/disk-test scaled
  2. Confirm 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 file system inside the pod reflects the new size.

    kubectl exec -it disk-test-0 -- df /data

    Expected output:

    Filesystem     1K-blocks  Used Available Use% Mounted on
    /dev/vdb        30787536    24  30771128   1% /data

    The mount path /data now shows 30 GiB, confirming the expansion is complete.

What's next