You can resize a system disk or a data disk offline based on your actual needs. After you restart the instance by using the console or by calling an API operation, the changes take effect.

Prerequisites

The disk to be resized is in the In Use (In Use) state and the instance to which the disk is attached is in the Running (Running) or Stopped (Stopped) state.

Background information

In offline mode, you can see that disks are resized only after you restart instances by using the console or by calling the RebootInstance operation. If an ECS instance is restarted from within the instance itself, the changes will not take effect. For more information, see Restart an instance.

Note
  • To prevent data loss, create snapshots to back up your data. For more information, see Create a snapshot.
  • If a data disk adopts the MBR partition format, you cannot resize the data disk to more than 2 TiB. If you want to resize a data disk to 2 TiB while the MBR partition format is used, we recommend that you create and attach another data disk. Format a GPT partition and copy the data in the MBR partition to the GPT partition.
The following limits apply when you resize disks offline:
  • For more information about capacity limits of resizing system disks and data disks, see Overview.
  • You can resize only basic disks, ultra disks, standard SSDs, and enhanced SSDs (ESSDs).
  • After you renew a subscription instance and downgrade its configurations, you cannot resize the subscription disks attached to the instance during the remainder of the current billing cycle.

Step 1: Create a normal snapshot

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Storage & Snapshots > Disks.
  3. In the top navigation bar, select a region.
  4. Select a disk category, and then click Create Snapshot in the Actions column.
  5. In the dialog box that appears, complete the following operations:
    1. Enter a snapshot name in the Snapshot Name field.
    2. Binds one or more tags to the snapshot.
    3. Click OK.
  6. In the Storage & Snapshots > Snapshots view the snapshot task.

Step2: Resize a single disk offline

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Storage & Snapshots > Disks.
  3. In the top navigation bar, select a region.
  4. Find the disk to be resized and choose More > Resize Disk in the Actions column.
  5. Set the Capacity after Resizing parameter. The value cannot be smaller than the current capacity.
  6. Confirm the fee, read and select ECS Service Terms and Product Terms of Service, and then click Resize.
  7. Read the notes and complete the payment.
  8. Restart the instance for the changes to take effect.
    Note You can see that the disk is resized only after you restart the instance by using the console or by calling the RebootInstance operation. If the ECS instance is restarted from within the instance itself, the changes will not take effect. For more information, see Restart an instance.

Step 3: View the disks partition.

  1. Remotely connect to an ECS instance.
  2. Run the fdisk -lucommand to check the current disk size.
    查看云盘分区情况
    No. Partition Description
    /dev/vda1 In the case of "System"="Linux", the system disk uses the MBR partition table format.
    /dev/vdb1 In the case of "System"="Linux", the data disk uses the MBR partition table format.
    /dev/vdc1 In the case of "System"="GPT", the data disk uses the GPT partition table format.
  3. Run the blkid command to check the file system type.
    查看文件系统

Step 4: Resize partitions

  1. Remotely connect to an ECS instance.
  2. Install gdisk.
    If your partition is in GPT format, you must perform this step. If your partition is in MBR format, you can skip this step.
    yum install gdisk -y
  3. Run the growpart /dev/vda 1command to resize the partition.
    The following example shows that the first partition /dev/vda1 of the system disk is resized.growpart

Step 5: Resize the file system

  1. Remotely connect to an ECS instance.
  2. You can use one of the following methods based on your file system type.
    • If the file system is ext*, such as ext3 and ext4, run theresize2fs /dev/vda1command.
      # Resize the file system of system disks (/dev/vda1)
      resize2fs /dev/vda1
      
      # Resize the file system of data disks (/dev/vdb1)
      e2fsck -f /dev/vdb1     // Check the status of the file system
      resize2fs /dev/vdb1
      Note You need to modify the partition name (/dev/vda1 and /dev/vdb1) according to the actual situation.
    • If the file system is XFS, run thexfs_growfs /media/vdccommand.
      Note You need to modify the mount point (/media/vdc) according to the actual situation.
  3. Run thedf -Thcommand to check the size of the disk partition.
    查看扩容结果