Detaching an Elastic Block Store Volume on Windows

Articles & Tutorials>Detaching an Elastic Block Store Volume on Windows
In order to protect disk integrity when detaching a volume from a Windows instance, the Amazon EC2 API will often return an error when there are processes writing to the volume. Follow these steps to safely detach a volume on Windows.

Details

Submitted By: Manoj@AWS
AWS Products Used: Amazon EC2
Created On: November 5, 2008 12:23 AM GMT
Last Updated: November 5, 2008 6:32 PM GMT

Introduction

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:

  1. 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.
  2. Follow the instructions below to safely detach a volume.

Tools Used

Detaching a Volume

  1. From the Start Menu, select "Command Prompt".
  2. 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:

  3. 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:\

  4. 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.
  5. 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:

  6. Once the buffers have been flushed, use the mountvol tool to detach the volume.

    C:\> mountvol e: /d

  7. Once the drive association has been removed, detach the EBS volume.

    C:\> ec2-detach-volume <volume-id>

Comments

Nice explanation, but the procedure suck
Explanation is clear, but the procedure just suck. How about automating it by 1) Providing the technet software on all instance instead of downloading it 2) Providing a script that does it from an "Amazon EC2 Control" button in the "Control Panel" or automating it with WinAutomation or some software like that. Carl malartre@scolab.com
camalartre on November 25, 2008 8:40 PM GMT
We are temporarily not accepting new comments.
©2014, Amazon Web Services, Inc. or its affiliates. All rights reserved.