You can detach a system disk from an ECS instance and attach it to another ECS instance as a data disk to migrate data. You can also do this to repair a corrupted system disk that prevents the source instance from starting. After the repair, you can reattach the disk to the source instance as its system disk. This topic describes how to detach and attach a system disk for an ECS instance.
Usage notes
After a system disk is detached, the following operations are not supported on the source ECS instance and the system disk:
-
Start the instance
-
Change the billing method for the instance
-
Change the instance type
-
Change the public bandwidth
-
Create a custom image
-
Release the system disk separately
-
Replace the system disk
-
Resize the system disk
-
Change the billing method for the disk
Detach the system disk
Prerequisites
Before you detach the system disk, make sure that the following requirements are met:
-
You have created a snapshot to back up the data on the system disk. For more information, see Create a snapshot.
-
The associated ECS instance must be in the Stopped state.
-
If the ECS instance was created from a custom image, make sure that the custom image has not been deleted.
-
The image used by the ECS instance is not an Alibaba Cloud Marketplace image or a custom image created from an Alibaba Cloud Marketplace image.
Procedure
Go to ECS console - Instances.
In the top navigation bar, select the region and resource group of the resource that you want to manage.
-
Find the ECS instance that is in the Stopped state and click the instance ID.
-
On the Instance Details page, click the Block Storage tab.
-
In the Actions column of the System Disk, select .
-
In the Detach Disk dialog box, click OK.
Note-
By default, Release Disk with Instance is enabled. If this option is enabled, the system disk is released when the source instance is released, even if the disk is detached or attached to another instance as a data disk.
-
If you disable Release Disk with Instance, the system disk is retained as a pay-as-you-go data disk after the source instance is released.
-
-
Verify the result.
-
Return to the Instances page. The Status of the ECS instance changes to No System Disk, and the tag
acs:ecs:sourceSystemDiskIdis added to the instance. -
In the left-side navigation pane, choose .
-
The system disk is converted into a data disk, and its Status changes to Detached System Disk. Three tags are added to the disk:
acs:ecs:sourceInstanceId,acs:ecs:diskDeleteProtection, andacs:ecs:diskPayType. The billing method of the disk remains unchanged.
The following tags are added to help you find the resources:
Tag key
Description
Value
acs:ecs:sourceSystemDiskIdThe ID of the system disk that was detached from the instance.
The disk ID.
acs:ecs:sourceInstanceIdThe instance to which the system disk belongs.
The instance ID.
acs:ecs:diskDeleteProtectionPrevents the disk from being manually released.
trueacs:ecs:diskPayTypeThe billing method of the disk.
Same as before detachment.
-
Prepaid: subscription -
AfterPay: pay-as-you-go
-
Attach as a data disk
After you detach the system disk, you can attach it to another ECS instance in the same zone as a data disk to migrate data or repair files. For more information, see Attach a data disk.
Attach as a system disk
If a corrupted system disk prevents an ECS instance from starting, you can detach it for repair. This involves attaching it to another ECS instance as a data disk, and then reattaching it to the source instance as a system disk after the repair is complete.
Prerequisites
Before you attach the system disk, make sure that the target ECS instance meets the following requirements:
-
The instance is in the No System Disk state.
-
The instance is the one from which the system disk was detached.
Procedure
Go to ECS console - Instances.
In the top navigation bar, select the region and resource group of the resource that you want to manage.
-
Detach the repaired disk from the ECS instance that you used for repair.
For more information, see Detach a data disk.
-
Find the source ECS instance that is in the No System Disk state. In the Actions column, click Attach Disk.
-
In the Attach Disk dialog box, configure the following options.
-
In the Source System Disk text box, enter the ID of the Disk.
-
Configure the attachment options.
Parameter
Description
Example
Logon Username
The username for logging on to the ECS instance.
WarningThe
rootuser has the highest permissions on the operating system. Usingrootas the username may pose security risks. We recommend that you use a standard user, such asecs-user.ecs-userLogon Credential
When you attach a system disk, you must set the logon credentials for the ECS instance:
-
Key Pair: for Linux instances only.
-
Password: for both Windows Server and Linux instances. The password applies only to the
administrator(Windows Server),root, orecs-user(Linux) username. It does not apply to other usernames.
Key Pair
Release Mode
Release Disk with Instance: Determines if the disk is released (deleted) when the instance is released.
-
Selected: The disk is released with the instance.
-
Cleared: The system disk is retained as a pay-as-you-go data disk.
Cleared
Delete Automatic Snapshots While Releasing Disk: Determines if automatic snapshots are deleted when the disk is released.
-
Selected: The automatic snapshots are deleted.
-
Cleared: The automatic snapshots are retained.
Selected
-
-
Click Next.
-
> Detach