DetachDisk

Last Updated: Jan 17, 2018

Description

Detaches a cloud disk from a specified instance. When you call this interface, consider the following.

  • The cloud disk that is going to be detached must meets the following conditions.

    • The Portable attribute of the cloud disk must be True.
    • The status of the specified cloud disk must be In_Use.
    • The status of the specified instance must be Running or Stopped.
    • If the specified instance is locked, its OperationLocks of the instance cannot be "LockReason" : "security".
  • After a cloud disk is detached, the DeleteWithInstance attribute of the target cloud disk is automatically set to fasle.

  • The action of DetachDisk is asynchronous, you may wait for a few minutes before the action is completed, and the duration is about one minutes.

Request parameters

Name Type Required Description
Action String Yes The name of this interface. Value: DetachDisk.
InstanceId String Yes The ID of the target ECS instance.
DiskId String Yes The ID of the disk.

Response parameters

All are common response parameters. For more information, see Common parameters.

Examples

Request example

  1. https://ecs.aliyuncs.com/?Action=DetachDisk
  2. &InstanceId=i-23jggx34b
  3. &DiskId=d-23jbf2v5m
  4. &<Common Request Parameters>

Response example

XML format

  1. <DetachDiskResponse>
  2. <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
  3. </DetachDiskResponse>

JSON format

  1. {
  2. "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
  3. }

Error codes

Error code Error message HTTP status code Meaning
MissingParameter The input parameter InstanceId that is mandatory for processing this request is not supplied. 400 You must specify a InstanceId.
MissingParameter The input parameter DiskId that is mandatory for processing this request is not supplied. 400 You must specify a DiskId.
DependencyViolation The specified disk has not been attached on the specified instance. 403 The specified disk is not attached to the specified instance.
DiskNotPortable The specified disk is not a portable disk. 403 The specified disk cannot be detached.
DiskTypeViolation The specified disk is a system disk and cannot support the operation. 403 You cannot detach a system disk from your instance.
IncorrectDiskStatus The current disk status does not support this operation. 403 The status of the specified cloud disk must be In_Use.
InstanceLockedForSecurity The instance is locked due to security. 403 The specified instance is locked for the sake of security.
InvalidDiskId.NotFound The specified disk does not exist. 404 The specified disk does not exist.
InvalidInstanceId.NotFound The specified InstanceId does not exist. 404 The specified instance does not exist.
Thank you! We've received your feedback.