Currently, Elastic Compute Service (ECS) does not support system disk or data disk shrink. If you want to shrink your disk volumes, try Alibaba Cloud Migration Tool instead.

Though Cloud Migration Tool is designed to balance the cloud-based and offline workloads of Alibaba Cloud users, you can use it to shrink ECS disk volumes.

The tool creates a custom image based on your ECS instance. During this process, it re-specifies the size of the disk to shrink it. Apart from replacing the target object with an ECS instance, the tools for cloud migration and disk volume shrinking are identical, in terms of both operation and limitations. Because the ECS instance is already virtual, it is more convenient to use and the chances of reporting errors is reduced.

However, using this tool may change some attributes of the ECS instance. For example, instance ID (InstanceId) and public IP. If your instance is a VPC-Connected instance, you can reserve the public IP address by converting public IP address to EIP address. We recommend that users using Alibaba Cloud Elastic IP (EIP) and users with less dependency on public IP use this approach to shrink the disk.

Prerequisites

  • When the disk is mounted on a Linux instance, you must first install rsync, a remote data synchronization tool.
    • CentOS Instance: Run yum install rsync –y.
    • Ubuntu Instance: Run apt-get install rsync –y.
    • Debian Instance: Run apt-get install rsync –y.
    • Other distributions: Please visit the official website to find the relevant installation documents.
  • You must create an AccessKey in the console first, which is used to output it into the configuration file user_config.json.
    Note To prevent data leakage due to excessive permissions for AccessKey, we recommend that you create a RAM sub-account and use this account to create an AccessKey.
  • For other prerequisites and limitations, see migrate to Alibaba Cloud by using Cloud Migration Tool.

Procedure

  1. Connect to the target ECS instance by using the administrator/root account.
  2. Download the Alibaba Cloud Migration Tool zip file.
  3. Unzip the Cloud Migration Tool. Enter the corresponding operating system and version of the client file directory to find the configuration file user_config.json.
  4. See customize user_config.json to complete the configuration.

    See the following figure for the configuration file in a Linux instance.



    The most important parameters to configure for shrinking a disk volume are as follows:

    • system_disk_size: Set this parameter to the expected system disk size in GB. The value cannot be less than the actual size of the system disk.
    • data_disks: Set this parameter to the expected data disk size in GB. The value cannot be less than the actual size of the data disk.
    Note
    • When a Linux instance comes with a data disk, the data_disks parameter is required even if you do not want to shrink the data disk volume. If it is not configured, Cloud Migration Tool copies data from the data disk to the system disk by default.
    • When a Windows instance comes with a data disk, the data_disks parameter is optional if you do not want to shrink the size of the data disk.
  5. Run the program go2aliyun_client.exe:
    • Windows instance: Right-click go2aliyun_client.exe and select Run as administrator.
    • Linux instance:
      1. Run chmod +x go2aliyun_client to give the client executable permissions.
      2. Run ./ go2aliyun_client to run the client.
  6. Wait for the running results:
    • If Goto Aliyun Finished! is displayed, go to the ECS console and check the custom image after shrinking. If the custom image has been generated, you can release the original instance and use the custom image to create an ECS instance. After you create a new instance, the disk volume shrinking process is complete.
    • If Goto Aliyun Not Finished! is displayed, check the log files in the same directory for troubleshooting. After fixing any problems, run Cloud Migration Tool again to resume volume shrinking. The tool continues the most recent migration progress and does not start over.

References