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 offline (Linux)

Last updated:2021-07-21 17:45:42

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. If your KEC instance does not support the online capacity expansion of EBS volumes, you can use the offline capacity expansion feature. After you expand the capacity of an EBS volume offline, you must restart the KEC instance to which the EBS volume is attached. This will interrupt your business. Therefore, we recommend that you perform an offline capacity expansion during off-peak hours. This topic describes how to perform an offline capacity expansion on an EBS volume attached to a KEC instance whose operating system 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 offline 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 or Stopped state.
2. All types, including GPU types, of KEC instances support the offline capacity expansion of EBS volumes.
3. During the offline 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 offline capacity expansion.
EBS volume 1. The EBS volume for which you want to expand the capacity offline must be in the In use or To be mounted 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 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 and restart or start the KEC instance

  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 and 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.
  5. Restart or start the KEC instance to which the EBS volume is attached.

    Note:
    1. After the capacity expansion, if the KEC instance to which the EBS volume is attached is in the Running state, you must restart the KEC instance in the console. If the KEC instance is in the Stopped state, you must start the KEC instance in the console. You can view the expanded capacity of the EBS volume only after you restart the KEC instance in the console or by calling the corresponding API operation.
    2. If you want to expand the capacity of a data disk in the To be mounted state, you can perform an offline capacity expansion in the EBS console. After that, attach the disk to a KEC instance. The expanded capacity will be immediately recognized.
    3. 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. After you start the KEC instance, log in to the KEC console and connect 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 Debian 9 or Ubuntu 14 and above, run the following command:
      apt-get install -y cloud-guest-utils
    • If the operating system is Debian 8.2, run the following command
      apt-get install -y cloud-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:
      1.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.If you execute the expand file system command, you will get the following prompt:
      resize2fs 1.42.12 (29-Aug-2014)
      Please run'e2fsck -f /dev/vdb1' first .
      Please execute the e2fsck -f /dev/vdb1 command first to check the file system.

  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