You cannot shrink Elastic Compute Service (ECS) disks, including system disks and data disks, after the disks are created. If you require a smaller disk, you can use Server Migration Center (SMC) to migrate data from the source disk that you want to shrink to a smaller disk or purchase a smaller disk to replace the source disk that you want to shrink, and then release the source disk.
When you shrink a disk, you must consider various factors, such as data security, business continuity, and costs. This topic provides guidelines to help you better plan the disk shrinking process based on your business requirements and describes how to shrink disks.
When you use the SMC migration method or purchase a disk to shrink a source disk that is attached to an instance, the shrink process may require an instance stop and restart to complete data migration and configuration modification, which may interrupt your workloads. To minimize the impact on your workloads, we recommend that you perform the operations during off-peak hours.
Prerequisites
We recommend that you create snapshots for disks to back up data. For more information, see Create a snapshot.
You are charged for the snapshots. For more information, see Billing of snapshots.
Use SMC to shrink disks
SMC is developed to balance cloud-based and offline workloads for Alibaba Cloud users. You can use SMC to shrink ECS disks. If you want to use SMC to shrink a disk attached to an ECS instance, you can migrate data from the migration source to a custom image or another ECS instance that has the required disk capacity. The source and destination ECS instances can belong to the same Alibaba Cloud account or different Alibaba Cloud accounts. For more information, see Migrate data between ECS instances that belong to the same Alibaba Cloud account or different Alibaba Cloud accounts.
This mode applies to system disks and data disks.
Considerations
SMC creates a pay-as-you-go intermediate instance during migration. You are charged for the intermediate instance.
NoteIf the migration is successful, the intermediate instance is automatically released. If the migration fails, the intermediate instance remains together with the migration task and the billing continues. To prevent unnecessary fees, you can manually release the intermediate instance. For more information, see Clear resources.
After the migration, the ID and IP address of the ECS instance are changed. Change the IP address of the ECS instance if your business involves IP address configuration. For information about the impacts of the migration, see Impacts.
Procedure
Linux
The preparations for the migration of the source ECS instance are complete. For more information, see Before you begin.
Import the Linux instance whose disks you want to shrink as a migration source to SMC.
Select ECS Instance as Migration Source Type. For more information, see Step 1: Import the information about a migration source.
Create and start a migration job.
When you create a migration job, take note of the following parameters:
Destination Type: Select ECS Image.
In the Modify Disk Partition section, the partition type of the destination disk is automatically set to the partition type of the source disk. You can specify Disk Size of the destination disk based on your business requirements.
Turn off Block Replication.
You can change the partition size in the Linux operating system only if block replication is disabled.
Change the disk size and partition size. The size of the destination disk cannot be smaller than the used capacity of the source disk and must be larger than the total size of all partitions.
For example, if the size of the source disk is 50 GiB and the size of the new disk is 40 GiB, you must change the partition size.
For more information, see Step 2: Create and start a migration job.
After the migration is complete, a custom image is generated. In the Actions column of the migration job, click Create Instance. You are redirected to the ECS instance buy page in the ECS console to create an ECS instance.
The custom image information is automatically filled in.
The default system disk category and size may be different from those of the source disk that you want to shrink. You can change the system disk category and size based on your business requirements.
Configure the other parameters. For more information, see Create an instance by using a custom image.
Windows
Compress the partitions of the source disk to the required capacity by using the Shrink Volume feature.
If the migration source is a Windows operating system, the block replication feature is automatically enabled and cannot be disabled. Therefore, you must compress the volumes before migration. For more information, see Steps 1 through 5 in Repartition a Windows disk by shrinking a volume.
For example, if the source disk (disk C) has only one partition that has a capacity of 40 GB, the disk can be compressed into two partitions that have an allocated capacity of 20.47 GB and an unallocated capacity of 19.53 GB.
The preparations for the migration of the source ECS instance are complete. For more information, see Before you begin.
Import the Windows instance whose disks you want to shrink as a migration source to SMC.
Select ECS Instance as Migration Source Type. For more information, see Step 1: Import the information about a migration source.
Create and start a migration job.
When you create a migration job, take note of the following parameters:
Destination Type: Select ECS Image.
In the Modify Disk Partition section, the partition type of the destination disk is automatically set to the partition type of the source disk. You can specify the size of the destination disk based on your business requirements.
NoteThe disk capacity must be greater than the total partition size. Because you compressed the partition size on the source disk, you must change the size of the destination disk.
For example, you can change the size of the destination disk to 30 GiB if the size of the source disk is 40 GiB.
For more information, see Step 2: Create and start a migration job.
After the migration is complete, a custom image is generated. In the Actions column of the migration job, click Create Instance. You are redirected to the ECS instance buy page in the ECS console to create an ECS instance.
The custom image information is automatically filled in.
The default system disk category and size may be different from those of the source disk that you want to shrink. You can change the system disk category and size based on your business requirements.
Configure the other parameters. For more information, see Create an instance by using a custom image.
Purchase a disk to shrink an existing disk
This mode applies only to data disks.
System disk: The system disk is created with the instance and cannot be separately created or released. Therefore, you cannot purchase a system disk to reduce the size of the existing system disk.
Data disk: You can purchase a new data disk whose capacity is set to the required capacity, attach the new data disk to the source ECS instance, and then copy the data from the source data disk to the new data disk.
ImportantIf a dependency exists between a data disk and the system disk, your business may be interrupted when you perform the disk shrinking operation on the data disk or change the configuration file of the data disk. To minimize the impact on your business, we recommend that you perform the operations during off-peak hours.
Perform the following steps:
Create an empty data disk and set the size of the new data disk to the required size.
For more information, see Create an empty data disk.
Attach the new data disk to the source ECS instance and initialize the data disk.
For more information, see Attach a data disk.
Copy data from the source data disk to the new data disk.
After the data replication is complete, you must check the data integrity and correctness on the new data disk.
(Conditionally required) If an application directly references a specific drive letter or path of the source data disk, you must update the relevant settings in the configuration file after the data disk is replaced.
Detach and release the source data disk to prevent unnecessary costs.
For more information, see Detach a data disk and Release a disk.