| Did this page help you? Yes No Tell us about it... |
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, go to 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. |
The short version of this command is ec2detvol.
ec2-detach-volume
volume_id [--instance instance_id [--device
device]] [--force]
| Name | Description | Required |
|---|---|---|
|
|
The ID of the volume. Type: String Default: None Example: vol-4282672b |
Yes |
|
|
The ID of the instance. Type: String Default: None Example: -i i-6058a509 |
No |
|
|
The device name. Type: String Default: None Example: -d /dev/sdh |
No |
|
|
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 will not 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 Example: -f |
No |
| Option | Description |
|---|---|
|
|
Overrides the Region specified in the Default: The Example: |
|
|
Default: The Example: |
|
|
The private key to use when constructing requests to Amazon EC2. Default: The value of the Example: |
|
|
The X.509 certificate to use when constructing requests to Amazon EC2. Default: The value of the Example: |
|
|
Specifies a connection timeout (in seconds). Example: --connection-timeout 30 |
|
|
Specifies a request timeout (in seconds). Example: --request-timeout 45 |
|
|
Displays verbose output by showing the SOAP request and response on the command line. This is particularly useful if you are building tools to talk directly to our SOAP API. |
|
|
Displays column headers in the output. |
|
|
Shows empty columns as |
|
|
Do not display tags for tagged resources. |
|
|
Prints internal debugging information. This is useful to assist us when troubleshooting problems. |
|
|
Displays Help. |
|
|
If Example: |
The command returns a table that contains the following information:
ATTACHMENT identifier
ID of the volume
ID of the instance
Device as which the volume is exposed within the instance
Attachment state (e.g., detaching)
Time stamp when detaching was initiated
Amazon EC2 command line tools display errors on stderr.
This example detaches volume vol-4d826724.
PROMPT>ec2-detach-volume vol-4d826724ATTACHMENT vol-4d826724 i-6058a509 /dev/sdh detaching 2008-02-14T00:00:17+0000