All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

Expand the capacity of an EBS volume online (Linux)

Last updated:2021-07-01 14:36:43

If the storage space of an EBS volume, either a system disk or data disk, no longer meets your business requirements, you can expand the capacity of the EBS volume. This topic describes how to expand the capacity of an EBS volume without the need to suspend the KEC instance to which the EBS volume is attached. In this topic, the operating system of the KEC instance is Linux.

Scenarios

EBS volumes are scalable storage devices. You can expand the capacity of an existing EBS volume at any time to increase its storage space without affecting the data on the EBS volume. After you expand the capacity of an EBS volume in the EBS console, you need to allocate the expanded capacity to partitions. The partitions can be existing partitions or partitions that are newly created and formatted. Then, resize the file systems of the partitions, so that the expanded capacity can be recognized. For more information, see Resize partitions and file systems (Linux).

Note:
The maximum capacity of an EBS volume that uses MBR partitioning is 2 TB. If the capacity exceeds this limit, the excess capacity cannot be used. You may need to expand the capacity of an EBS volume that uses MBR partitioning to more than 2 TB. In this case, we recommend that you create and attach a data disk that uses GPT partitioning and then copy the data to the new disk.

Prerequisites

The following table describes the requirements that must be met before an online capacity expansion is performed on an EBS volume attached to a KEC instance whose operating system is Linux. Cloud product Limit
KEC instance 1. The KEC instance must be in the Running state.
2. All types, including GPU types, of KEC instances support the online capacity expansion of EBS volumes.
3. During the online capacity expansion, the status of the KEC instance cannot be changed. For example, you cannot restart, shut down, or delete the KEC instance.
4. All KEC instances to which SSD volumes of EBS 3.0 or EHDD volumes can be attached support online capacity expansion.
5. The public or custom image used by the KEC instance must support the online capacity expansion of EBS volumes. For more information, see the following table.
EBS volume 1. The EBS volume for which you want to expand the capacity online must be in the In use state.
2. The EBS volume must be an SSD volume of EBS 3.0 or an EHDD volume.
3. The capacity after the expansion must be greater than the original capacity but cannot exceed the corresponding upper limit. For more information about the upper limits on capacity, see Overview.
Operating systems that support the online capacity expansion of EBS volumes The following table describes the Linux images that support the online capacity expansion of EBS volumes. Such Linux images include public Linux images, and custom Linux images created based on public images. Operating system
Version
CentOS 7 7.X 64-bit version
CentOS 8 8.X 64-bit version
Debian 9 9.6 64-bit version
Debian 10 10.6 64-bit version
Ubuntu Server 14 14.04 64-bit version
Ubuntu Server 16 16.04 64-bit version
Ubuntu Server 18 18.04 64-bit version
Ubuntu Server 20 20.04 64-bit version
Fedora 20 64-bit version

Note:
If your KEC instance does not support the online capacity expansion of EBS volumes, you can use the offline capacity expansion feature. For more information, see Expand the capacity of an EBS volume offline (Linux).

Operating environment

Resource
Description
Operating system CentOS 8.2 64-bit
System disk /dev/vda: uses MBR partitioning and ext4 file systems. You want to expand the capacity of the disk from 50 GB to 70 GB.
Data disk /dev/vdb: uses MBR partitioning and ext4 file systems. You want to expand the capacity of the disk from 50 GB to 100 GB.
/dev/vdc: uses GPT partitioning and xfs file systems. You want to expand the capacity of the disk from 50 GB to 150 GB.

Step 1: Create a snapshot

Note: To prevent data loss caused by misoperations, we recommend that you create a snapshot to back up data before you expand the capacity of an EBS volume.

  1. Log in to the EBS console.
  2. In the left navigation pane, click EBS.
  3. In the upper-left corner, select a region.
  4. On the EBS tab, find the EBS volume for which you want to expand the capacity and click Create Snapshot in the Operation column.
  5. In the dialog box that appears, enter a name and description for the snapshot and click OK. The snapshot is immediately created.
  6. In the left navigation pane, choose Snapshot > Snapshot List to view the creation process of the snapshot.
    After the progress reaches 100% and the status of the snapshot becomes Available, you can proceed to the next step.

Step 2: Expand the capacity of the EBS volume in the EBS console

  1. Log in to the EBS console.
  2. On the EBS tab, find the EBS volume for which you want to expand the capacity and choose More > Capacity Expansion in the Operation column.
  3. In the Capacity Expansion dialog box, read the instructions, select the Online expansion check box, and then set the Capacity parameter.
    The capacity after the expansion must be greater than the original capacity.
  4. On the Confirm Order page, click Submit Order. Then, complete the payment.

    Note:
    1. If an EBS volume qualifies for online capacity expansion but you do not select the Online expansion check box, an offline capacity expansion will be performed on the EBS volume.
    2. After you expand the capacity of an EBS volume in the EBS console, the expanded capacity is not available for use yet. You must log in to the operating system of the KEC instance to which the EBS volume is attached, and allocate the expanded capacity by resizing partitions and file systems.

Step 3: View the partition information about the EBS volume

  1. Log in to the KEC instance. For more information, see Connect to instances.
  2. Run the following command to view the information about the EBS volumes attached to the KEC instance:
    fdisk -l
The following figure shows the output. image.png The following table describes the information extracted from the figure. EBS volume Partition Partition description
/dev/vda is the system disk with a capacity of 70 GB. /dev/vda1 MBR partition, with a capacity of 50 GB
/dev/vdb is the data disk with a capacity of 100 GB. /dev/vdb1 MBR partition, with a capacity of 50 GB
/dev/vdc is the data disk with a capacity of 150GB. /dev/vdc1 GPT partition, with a capacity of 50GB

Note:
If the output shows that the capacity of the EBS volume for which you have expanded the capacity is still the same as the original capacity, the capacity expansion failed. We recommend that you restart the KEC instance in the console.

  1. Run the following command to view the information about the partitions on the EBS volumes attached to the KEC instance:
    df -Th
    The following figure shows the output. image.png The following table describes the information extracted from the figure. Partition File system type Mount point
    /dev/vda1 ext3 Mounted to /
    /dev/vdb1 ext4 Mounted to /mnt/data_disk01
    /dev/vdc1 xfs Mounted to /mnt/data_disk02

    Step 4: Resize partitions

  2. Install the gdisk tool by running one of the following commands as needed. If the EBS volume for which you have expanded the capacity uses MBR partitioning, skip this step. If the EBS volume for which you have expanded the capacity uses GPT partitioning, run one of the following commands based on the operating system of your KEC instance.
    • If the operating system is CentOS, run the following command:
      yum install gdisk -y
    • If the operating system is Ubuntu or Debian, run the following command:
      apt-get install gdisk -y
  3. Install the growpart tool by running one of the following commands based on the operating system of your KEC instance.
    • If the operating system is CentOS, run the following command:
      yum install -y cloud-utils-growpart
    • If the operating system is Ubuntu or Debian, run the following command:
      apt-get install -y cloud-guest-utils
  4. Run the following command to use the growpart tool to resize partitions:
    growpart /dev/vdb 1

    In this example, resize the /dev/vdb1 partition on the /dev/vdb data disk. Separate /dev/vdb and 1 with a space in the command. If you need to resize other partitions, modify the command as needed. The following figure shows the output. image.png

Step 5: Resize file systems

  1. In the operating system of your KEC instance, resize a file system by running one of the following commands based on the type of the file system.

    • If the type of the file system is in the format of ext*, such as ext4, run one of the following commands based on the type of the EBS volume.

      To resize the file system of the /dev/vda1 partition on the /dev/vda system disk, run the following command:

      resize2fs /dev/vda1

      To resize the file system of the /dev/vdb1 partition on the /dev/vdb data disk, run the following command:

      resize2fs /dev/vdb1

      The following figures show the output. image.png image.png

      Note: In the preceding commands, /dev/vda1 and /dev/vdb1 are partition names. You must change them based on your business requirements.

    • If the type of the file system is xfs, run the following command:
      xfs_growfs /mnt/data_disk02

      The following figure shows the output. image.png

      Note: In the preceding command, /mnt/data_disk02 is the mount point of the /dev/vdc1 partition. You must change it based on your business requirements.

  2. Run the following command to check the resizing results:
    df -Th

    The following figure shows the output. image.png The figure shows that the resizing succeeded. When you check the results, compare the results with the original capacities.

    • If the resizing succeeded, the business programs on the KEC instance can continue to run as expected.
    • If the resizing failed, use the snapshot to roll back the data.
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback