If you want to migrate data from the system disk of an Elastic Compute Service (ECS) instance to another ECS instance, you can detach the system disk from the source ECS instance and then attach it to the destination ECS instance as a data disk. If an ECS instance cannot be started because files on the system disk of the ECS instance are corrupted, you can also detach the system disk from the ECS instance and then attach it to another ECS instance as a data disk for repair. After the disk is repaired, attach it to the source ECS instance as the system disk. This topic describes how to detach and attach the system disk of an ECS instance.
Considerations
After the system disk is detached from an instance, the instance and the system disk do not support the following operations:
Start the instance.
Change the billing method of the instance.
Change the instance type.
Change the public bandwidth.
Create a custom image.
Separately release the system disk.
Replace the system disk.
Resize the system disk.
Change the billing method of the disk.
Detach the system disk
Prerequisites
Before you detach the system disk from an instance, make sure that the involved resources meet the following requirements:
Snapshots are created for the system disk of the instance that you want to manage to back up disk data. For more information, see Create a snapshot for a disk.
The instance is in the Stopped state because the system disk can be detached only offline.
If the ECS instance is created from a custom image, make sure that the custom image is not deleted.
The image used by the instance is not an Alibaba Cloud Marketplace image or a custom image that is created from an Alibaba Cloud Marketplace image.
Procedure
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
Find an instance that is in the Stopped state and click the ID of the instance.
On the Instance Details page, click the Block Storage (Disks) tab.
In the Actions column corresponding to the system disk, choose .
In the Detach Cloud Disk message, click OK.
NoteBy default, Release Cloud Disk with Instance is enabled for the system disk. The system disk belongs to the source instance. If Release Cloud Disk with Instance is enabled, the system disk is automatically released when the source instance is released, regardless of whether the system disk was detached from the source instance or is attached to another instance as a data disk.
If you clear Release Cloud Disk with Instance in the dialog box, the system disk is retained as a data disk when the source instance is released. Then, the disk is billed based on the pay-as-you-go billing method.
Check whether the system disk is detached.
Return to the Instance page. The No System Disk state is displayed in the Status column and the acs:ecs:sourceSystemDiskId tag is added to the ECS instance.
In the left-side navigation pane, choose .
The system disk is converted to a data disk. The Type column displays Detached System Disk. The system disk has the acs:ecs:sourceInstanceId, acs:ecs:diskDeleteProtection, and acs:ecs:diskPayType tags. The billing method remains unchanged.
The added instance tags and disk tags help you find resources. The following table describes the tag formats.
Tag key
Description
Tag value
acs:ecs:sourceSystemDiskId
The system disk of the instance.
The ID of the disk.
acs:ecs:sourceInstanceId
The instance to which the system disk is attached.
The instance ID.
acs:ecs:diskDeleteProtection
Indicates that the release protection feature is enabled for the disk. The disk cannot be manually released.
true
acs:ecs:diskPayType
The billing method of the disk.
The billing method of the disk before the disk was detached. Valid values:
Prepaid: subscription
AfterPay: pay-as-you-go
Attach the system disk to another ECS instance as a data disk for repair
After the system disk is detached, attach the system disk as a data disk to another ECS instance in the same zone for operations such as data migration and file repair. For more information, see Attach a data disk.
Attach the repaired disk back to the source ECS instance as the system disk
If the source ECS instance cannot start because files on the system disk are corrupted, you must attach the disk back to the source ECS instance as the system disk after you repair the disk.
Prerequisites
Before you attach the detached system disk to the source ECS instance as the system disk, make sure that the instance meets the following requirements:
The instance is in the No System Disk state.
The instance is the instance from which the system disk was detached.
Procedure
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
Detach the repaired disk from the ECS instance that you used to repair the disk.
For more information, see Detach a data disk.
Find the source instance that is in the No System Disk state. In the Actions column, click Attach Disk.
In the Attach Cloud Disk dialog box, perform the following operations:
Copy the ID of the source system disk and paste it in the Disk field.
Configure the parameters that are described in the following table.
Parameter
Description
Example
Username
The username to use to log on to the instance.
WarningIf you log on to an ECS instance as the root user, you have the highest permissions on the instance. However, security risks may arise. We recommend that you log on to the ECS instance as the ecs-user user.
ecs-user
Logon Credentials
The logon credentials for the instance.
Key Pair: Select this option only for Linux instances.
Password: You can select this option for Windows Server instances and Linux instances. This option takes effect only when the administrator username is used for Windows Server instances or when the root or ecs-user username is used for Linux instances.
Key Pair
Release Mode
Release Cloud Disk with Instance: specifies whether to retain the disk when the instance is released.
If this option is selected, the disk is released when the instance is released.
If this option is not selected, the disk is retained as a data disk and billed on a pay-as-you-go basis when the instance is released.
Do not select Release Cloud Disk with Instance
Delete Automatic Snapshots While Releasing Disk: specifies whether to retain automatic snapshots after the disk is released.
If this option is selected, the automatic snapshots are deleted when the disk is released.
If this option is not selected, the automatic snapshots are retained when the disk is released.
Select Delete Automatic Snapshots While Releasing Disk
Click Next.