Amazon Elastic Compute Cloud
API Reference (API Version 2013-02-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

DetachVolume

Description

Detaches an Amazon EBS volume from an instance. Make sure to unmount any file systems on the device within your operating system before detaching the volume. Failure to do so will result in volume being stuck in "busy" state while detaching. For more information about Amazon EBS, see Using Amazon Elastic Block Store in the Amazon Elastic Compute Cloud User Guide.

Note

If an Amazon EBS volume is the root device of an instance, it cannot be detached while the instance is in the "running" state. To detach the root volume, stop the instance first.

If the root volume is detached from an instance with an AWS Marketplace product code, then the AWS Marketplace product codes from that volume are no longer associated with the instance.

Request Parameters

VolumeId

The ID of the volume.

Type: String

Default: None

Required: Yes

InstanceId

The ID of the instance.

Type: String

Default: None

Required: No

Device

The device name.

Type: String

Default: None

Required: No

Force

Forces detachment if the previous detachment attempt did not occur cleanly (logging into an instance, unmounting the volume, and detaching normally). This option can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance. The instance won't have an opportunity to flush file system caches or file system metadata. If you use this option, you must perform file system check and repair procedures.

Type: Boolean

Default: None

Required: No

Response Elements

The following elements are returned in a DetachVolumeResponse element.

requestId

The ID of the request.

Type: xsd:string

volumeId

The ID of the volume.

Type: xsd:string

instanceId

The ID of the instance.

Type: xsd:string

device

The device name exposed to the instance.

Type: xsd:string

status

The attachment state.

Type: xsd:string

Valid values: attaching | attached | detaching | detached

attachTime

The time stamp when the attachment initiated.

Type: xsd:dateTime

Examples

Example Request

This example detaches volume vol-1a2b3c4d.

https://ec2.amazonaws.com/?Action=DetachVolume
&VolumeId=vol-1a2b3c4d
&AUTHPARAMS

Example Response

<DetachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
   <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
   <volumeId>vol-1a2b3c4d</volumeId>
   <instanceId>i-1a2b3c4d</instanceId>
   <device>/dev/sdh</device>
   <status>detaching</status>
   <attachTime>YYYY-MM-DDTHH:MM:SS.000Z</attachTime>
</DetachVolumeResponse>