You can call this operation to detach a pay-as-you-go data disk or a system disk from an ECS instance.
Description
When you call this operation, take note of the following items:
- The disk to be detached must be in the In Use (
In_Use
) state. - The instance from which you want to detach a data disk must be in the Running (
Running
) or Stopped (Stopped
) state. - The instance from which you want to detach a system disk must be in the Stopped (
Stopped
) state. - If the API response contains
{"OperationLocks":
{"LockReason" : "security"}}
when you query information of an instance, the instance is locked for security reasons and all operations are prohibited on it. - DetachDisk is an asynchronous operation. It takes about one minute for the disk to be detached after this operation is called.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | DetachDisk |
The operation that you want to perform. Set the value to DetachDisk. |
DiskId | String | Yes | d-bp67acfmxazb4p**** |
The ID of the disk to be detached. |
InstanceId | String | Yes | i-bp67acfmxazb4p**** |
The ID of the ECS instance from which the disk is to be detached. |
DeleteWithInstance | Boolean | No | false |
The automatic release attribute of the system disk. This parameter specifies whether the system disk is released when its attached instance is released. Valid values:
Default value: true. Note If a data disk is to be detached, the default value is
false .
|
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E |
The ID of the request. |
Examples
Sample requests
https://ecs.aliyuncs.com/?Action=DetachDisk
&DiskId=d-bp67acfmxazb4p****
&InstanceId=i-bp67acfmxazb4p****
&<Common request parameters>
Sample success responses
XML
format
<DetachDiskResponse>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
</DetachDiskResponse>
JSON
format
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
404 | InvalidInstanceId.NotFound | The specified InstanceId does not exist. | The error message returned because the specified instance ID does not exist. Check whether the instance ID is correct. |
404 | InvalidDiskId.NotFound | The specified disk does not exist. | The error message returned because the specified disk ID does not exist. Check whether the disk ID is correct. |
403 | IncorrectDiskStatus | The current disk status does not support this operation. | The error message returned because the operation is not supported while the disk is in the current state. Make sure that the disk is available and you have no overdue payments in your account. |
403 | DiskNotPortable | The specified disk is not a portable disk. | The error message returned because the specified disk is not removable when the Portable parameter is set to false. |
403 | InstanceLockedForSecurity | The instance is locked due to security. | The error message returned because the operation is not supported while the instance is locked for security reasons. |
403 | DependencyViolation | The specified disk has not been attached on the specified instance. | The error message returned because the operation is not supported while the resource has other dependencies. For example, the specified disk is not attached to the specified instance, or the specified security group cannot be deleted while it contains instances. |
403 | DiskTypeViolation | The specified disk is a system disk and cannot support the operation. | The error message returned because the specified disk is a system disk and cannot be detached from the instance to which it is attached. |
403 | IncorrectInstanceStatus | The current status of the resource does not support this operation. | The error message returned because the operation is not supported while the instance is in the current state. |
500 | InternalError | The request processing has failed due to some unknown error. | The error message returned because an internal error has occurred. Try again later. If the problem persists, submit a ticket. |
400 | InvalidParameter | The input parameter is mandatory for processing this request is empty. | The error message returned because a required parameter is not specified. |
403 | UserNotInTheWhiteList | The user is not in disk white list. | The error message returned because you are not in the whitelist to manage the disk. Try again when you are in the whitelist. |
400 | InvalidRegionId.MalFormed | The specified RegionId is not valid | The error message returned because the specified RegionId parameter is invalid. |
404 | InvalidDisk.AlreadyDetached | The specified disk has been detached. | The error message returned because the specified disk has been detached from the instance. |
400 | InvalidOperation.InstanceTypeNotSupport | The instance type of the specified instance does not support hot detach disk. | The error message returned because the instance to which the disk is attached does not support the hot swapping of disks. |
500 | InternalError | The request processing has failed due to some unknown error, exception or failure. | The error message returned because an internal error has occurred. Try again later. If the problem persists, submit a ticket. |
For a list of error codes, visit the API Error Center.