An Elastic Block Store (EBS) volume provides persistent, block-level storage for an instance and can be mounted as a disk or a mount point in Windows. In Windows, EBS volumes are mounted with write caching turned on to maximize I/O performance. In order to protect a volume's integrity, the EC2 API will return an error if you try to detach a volume that still has processes writing to the disk. If you receive an error message, you have two options:
- Forcing a volume to detach. This approach is not recommended; forcing an EBS volume to detach from an instance can result in data corruption due to the write caching. In some cases, the corruption can be severe enough that the NTFS volume can no longer be mounted on Windows.
- Follow the instructions below to safely detach a volume.
- Windows Command prompt, cmd.exe.
- Handle tool. Download the tool from http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx
- Sync tool. Download the tool from http://technet.microsoft.com/en-us/sysinternals/bb897438.aspx
- Mountvol tool, mountvol.exe.
Detaching a Volume
- From the Start Menu, select "Command Prompt".
- Determine the drive letter or mount point associated with the EBS volume. This can be done via the Disk Management tool.
C:\> diskmgmt.msc Let's say that the EBS volume is attached as E:
Use the Handle tool to determine if there are any file handles
open on the EBS Volume (E:).
C:\> handle e:\ Here is sample output from the handle tool: C:\> handle e:\ Handle v3.41 Copyright (C) 1997-2008 Mark Russinovich Sysinternals - www.sysinternals.com explorer.exe pid: 980 970: E:\
- If there are any open file handles, please close them by either terminating applications or by letting file transfers run to completion. In this case, the explorer view of E: needs to be closed.
Now that all file transfers to the selected drive have completed,
and all open file handles to the drive are closed, let's flush all file
buffers to the drive.
C:\> sync -r e:
Once the buffers have been flushed, use the mountvol tool to detach
C:\> mountvol e: /d
Once the drive association has been removed, detach the EBS volume.
C:\> ec2-detach-volume <volume-id>