How to Detach an Amazon EBS Volume from an Instance
An Amazon EBS volume can be detached from an instance by either explicitly detaching the volume or terminating the instance. This example unmounts the volume and explicitly detaches it from the instance. This is useful when you want to terminate an instance or attach a volume to a different instance.
Caution | |
---|---|
A volume must be unmounted inside the instance before being detached. Failure to do so will result in damage to the file system or the data it contains. |
To verify the volume is no longer attached to the instance, see How to Describe Snapshots.
AWS Management Console
To detach an Amazon EBS volume
-
For Linux/UNIX, enter the following command from the command line.
#
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.
-
Log in to the AWS Management Console and click the Amazon EC2 tab.
-
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.
Command Line Tools
To detach an Amazon EBS volume
-
Enter the following commands.
#
umount -d
/dev/sdh
PROMPT>
Amazon EBS returns information similar to the following example.
ATTACHMENT vol-4d826724 i-6058a509 /dev/sdh detaching 2008-02-14T00:00:17+0000
To detach an Amazon EBS volume by terminating the instance
-
Enter the following command.
PROMPT>
Amazon EBS returns information similar to the following example.
INSTANCE i-6058a509 running shutting-down