Detaches a pay-as-you-go data disk or a system disk from an Elastic Compute Service (ECS) instance.
Operation description
When you call this operation, take note of the following items:
- The disk that you want to detach must be in the
In_Use
state. - The instance from which you want to detach a pay-as-you-go data disk must be in the Running or Stopped state.````
- The instance from which you want to detach a system disk must be in the Stopped state.``
- If the
OperationLocks
parameter in the response contains"LockReason" : "security"
, the instance is locked for security reasons and no operations are allowed on the instance. - DetachDisk is an asynchronous operation. After you call the operation, a disk is detached from an instance in approximately 1 minute.
Debugging
Authorization information
There is currently no authorization information disclosed in the API.
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
InstanceId | string | Yes | The ID of the ECS instance from which you want to detach the disk. | i-bp67acfmxazb4p**** |
DiskId | string | Yes | The ID of the disk that you want to detach. | d-bp67acfmxazb4p**** |
DeleteWithInstance | boolean | No | Specifies whether to release the system disk when the instance from which you want to detach the system disk is released. Valid values:
Default value: true. If you specify this parameter, take note of the following items:
| false |
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | InvalidParameter | The input parameter is mandatory for processing this request is empty. | A required parameter is not specified. |
400 | InvalidRegionId.MalFormed | The specified RegionId is not valid. | The specified region does not exist. |
400 | InvalidOperation.InstanceTypeNotSupport | The instance type of the specified instance does not support hot detach disk. | - |
403 | IncorrectDiskStatus | The current disk status does not support this operation. | The disk is in a state that does not support the current operation. Make sure that the disk is available and that your account has no overdue payments. |
403 | DiskNotPortable | The specified disk is not a portable disk. | The specified disk is not removable. |
403 | InstanceLockedForSecurity | The instance is locked due to security. | 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. | - |
403 | DiskTypeViolation | The specified disk is a system disk and cannot support the operation. | The specified disk is a system disk and cannot be detached. |
403 | IncorrectInstanceStatus | The current status of the resource does not support this operation. | The resource is in a state that does not support the current operation. |
403 | UserNotInTheWhiteList | The user is not in disk white list. | You are not authorized to manage the disk. Try again when you are authorized. |
403 | InvalidInstance.ImageCategory | The image category of the specified instance does not support detaching system disk. | The specified system disk cannot be detached from the instance while the image of the instance is in the current state. Possible cause: The image that was used to create the instance has been deleted. |
403 | DeleteWithInstance.Conflict | Multi attach disk cannot be set to DeleteWithInstance attribute. | Disks for which the multi-attach feature is enabled do not support the DeleteWithInstance attribute. |
404 | InvalidInstanceId.NotFound | The specified InstanceId does not exist. | The specified instance does not exist. |
404 | InvalidDiskId.NotFound | The specified disk does not exist. | The specified disk does not exist. Check whether the disk ID is correct. |
404 | InvalidDisk.AlreadyDetached | The specified disk has been detached. | The specified disk has been detached. |
404 | InvalidDiskId.OperationNotSupported | The operation is not supported due to base image not exist. | - |
500 | InternalError | The request processing has failed due to some unknown error. | An internal error has occurred. Try again later. |
500 | InternalError | The request processing has failed due to some unknown error, exception or failure. | An internal error has occurred. Try again later. |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
2023-11-24 | The Error code has changed | see changesets | ||||||||||
|