You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
O&M
Batch expanding volume partitions and file systems
Copy page
Download PDF
Batch expanding volume partitions and file systems
This topic mainly describes how to use the cloud assistant feature to batch expand volume partitions and file systems without logging in to or restarting an instance.​
Applicable scenario​
As your business grows and application data increases, the current volume capacity is insufficient to store large amounts of business data. To solve this, you can expand your volume to increase storage capacity without losing existing data. By using the cloud assistant feature, you can batch expand file systems and partitions quickly without manually operating inside instances.​
Usage notes​
The expansion script provided in this practice only supports expanding volume partitions of the MBR type and the ext4 file systems. You can follow the guide for viewing partition and file system details to confirm the partition type and file system information of volumes mounted on your instances.​
Prerequisites​
Procedure​
Step 1: Expand volume​
  1. Log in to the ECS console. ​
  1. In the top menu bar, select the project and region of the target instance.​
  1. In the left-side navigation pane, select "Instances & Images > Instances".​
  1. On the Instances page, click the name of the target instance.​
  1. Select the "Volumes" tab.​
  1. On the right side of the target volume, select "... > Extend" in the "Actions" column.​
  1. On the Expand volume page, confirm the current configuration information. For the "New capacity" parameter, enter the volume capacity after expansion. In the example provided in this topic, the volume capacity is expanded to 60 GiB.​
  1. Click the "Extend volume" button to submit the expansion application.​
  1. After the volume is expanded in the console, follow the steps below for expanding partitions and file systems.​
Step 2: Create an expansion command​
  1. Log in to the ECS console. ​
  1. In the left-side navigation pane, select "Maintenance & Monitoring > Cloud Assistant". ​
  1. In the top menu bar, select the region where your business is located. ​
  1. Select the "Custom commands" tab to enter the custom command list page.​
  1. Click the "Create a custom command" button to enter the Create a custom command page.​
  1. Enter the following job information as instructed.​
This practice only describes necessary parameters. Other parameters remain with default values. For parameter details, refer to Creating custom commands.​
  • ​
    Parameter​
    Description​
    Sample value​
    Command name​
    Set the command name.​
    Expand volume partition and file system​
    Command type​
    Select "Shell".​
    Shell​
    Command contents​
    Enter information accordingly, and copy the complete content of the following script.​
    ​
    #!/bin/bash​
    set -x​
    #Check whether the growpart command is installed​
    CHECK_STATUS=$(yum versionlock status)​
    if [[ -z CHECK_STATUS ]];then​
    INSTALL_GROW_PART=$(yum install -y cloud-utils-growpart)​
    if [[ $? -ne 0 ]]; then​
    echo 'install cloud-utils-growpart failed'​
    exit 0​
    fi​
    fi​
    ​
    #Specify the partition to be expanded​
    LC_ALL=en_US.UTF-8 growpart {{volume}} {{partitionNumber}}​
    if [[ $? -ne 0 ]]; then​
    echo 'growpart failed'​
    exit 0​
    fi​
    ​
    #Synchronize the file system to the kernel based on the file system type​
    resize2fs {{volume}}{{partitionNumber}}​
    if [[ $? -ne 0 ]]; then​
    echo 'resize2fs failed'​
    exit 0​
    fi​
    ​
    #View the result​
    df -Th​
    ​
    -​
    Use argument​
    Check "Enable" to enable "Use argument".​
    -​
    ​
  1. Click the "Confirm" button to save the custom command.​
Step 3: Expand partition and file system​
  1. Log in to the ECS console. ​
  1. In the left-side navigation pane, select "Maintenance & Monitoring > Cloud Assistant". ​
  1. In the top menu bar, select the region where your business is located. ​
  1. Select the "Job management" tab.​
  1. Click the "Create a job" button and then enter job information based on the following instructions.​
This practice only describes necessary parameters. Other parameters remain with default values. For parameter details, refer to Creating jobs.​
  • ​
    Argument​
    Description​
    Sample value​
    Job name​
    Set the job name.​
    Expand volume partition and file system​
    Command type​
    Select Custom commands.​
    -​
    Command​
    Select the expansion command created in step 2.​
    Expand volume partition and file system​
    Parameter​
    Enter the information of the volume partition and file system to be expanded.​
    • volume: Enter the volume partition. For example, /dev/vdb.​
    • partitionNumber: Enter the volume partition number. For example, 1 .​
    -​
    Object​
    Select the instance associated with the target volume.​
    -​
    ​
  1. Click the "Confirm" button to complete the job creation.​
  1. After the job is created, the system automatically redirects you to the Job management page. The new job is then executed immediately.​
View expansion results​
  1. Log in to the ECS console. ​
  1. In the left-side navigation pane, select "Maintenance & Monitoring > Cloud Assistant". ​
  1. In the top menu bar, select the region where your business is located. ​
  1. Select the "Job management" tab, and then find the target job in the job list.​
  1. Click the target job name or the number in the "Execution object" column to open the job details page.​
  1. Select the "Execute object" tab to view the command execution results on each instance.​
  1. If the job is in Execution successful status, click the ​​ button to the left of the target instance name for details of the target partition.​
  • If the following output is displayed, the capacity of volume /dev/vdb1 is successfully expanded to 60 GiB.​
​
Last updated: 2026.06.18 17:49:51