| Did this page help you? Yes No Tell us about it... |
You can detach an Amazon EBS volume from an instance either by explicitly detaching the volume or terminating the instance. However, a volume must be unmounted inside the instance before being detached. Failure to do so will result in the volume being stuck in the busy state while it is trying to detach, which could possibly damage the file system or the data it contains.
This example explicitly unmounts the volume and then detaches it from the instance. This is useful when you want to terminate an instance or attach a volume to a different instance.
![]() | Note |
|---|---|
If an Amazon EBS volume is the root device of an instance, it cannot be detached unless the instance is in the stopped state. If the root volume is detached from an instance with an AWS Marketplace product code, then the AWS Marketplace product codes from that volume will no longer be associated with the instance. |
To detach an Amazon EBS volume
First unmount the volume from your instance drive.
For Linux/UNIX, enter the following command.
#umount -d/dev/sdh
For Windows, open Disk Management, right-click the volume to unmount, and select Change Drive Letter and Path. Then, select the mount point to remove and click Remove.
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
Click Volumes in the Navigation pane.
The console displays a list of current volumes.
Select a volume and click Detach Volume.
A confirmation dialog box appears.
Click Yes, Detach.
The volume is detached from the instance.
![]() | Caution |
|---|---|
If your volume stays in the detaching state, you can force the detachment using the Force Detach button. Forcing the detachment 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. |
To detach an Amazon EBS volume
Enter the following command.
#umount -d/dev/sdhPROMPT>ec2-detach-volume vol-4d826724
Amazon EC2 returns information similar to the following example.
ATTACHMENT vol-4d826724 i-6058a509 /dev/sdh detaching 2010-03-30T13:58:58+0000 ![]() | Caution |
|---|---|
If your volume stays in the detaching state, you can force the detachment
using the |
To detach an Amazon EBS volume
Construct the following Query request.
https://ec2.amazonaws.com/ ?Action=DetachVolume &VolumeId=volume-id&InstanceId=instance-id&...auth parameters...
Following is an example response.
<DetachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2012-04-01/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <volumeId>vol-4d826724</volumeId> <instanceId>i-6058a509</instanceId> <device>/dev/sdh</device> <status>detaching</status> <attachTime>2008-05-08T11:51:50.000Z</attachTime> </DetachVolumeResponse>
![]() | Caution |
|---|---|
If your volume stays in the detaching state, you can force the detachment
using the |
To verify the volume is no longer attached to the instance, see Describing Volumes and Instances.