Vista refuses to safely remove external usb hard drive
I have no programs accessing anything on my external usb hd, and no explorer
windows or command prompts running. The activity light on the drive shows no
activity. When I click the "safely remove hardware" icon in the task tray
and click "safely remove usb mass storage device - drive (f:)" it says
"Windows can't stop your 'generic volume' device because it is in use." and
immediately the external drive goes into a flurry of activity with its
activity light staying on almost constantly. Windows resource monitor shows
that svchost is the culprit, reading the drive at about 2MB/sec
continuously. Sysinternals process explorer confirms that nothing besides
"System" and "svchost.exe" have any handles open for the drive. The disk
activity continues for several minutes, then stops. If I try "safely remove
hardware" again, it again refuses, and goes into another flurry of disk
activity. The result is that I can't safely remove the device, unless I shut
down the machine first, which kind of defeats the point of usb drives being
hot pluggable. This is infuriating.
Re: Vista refuses to safely remove external usb hard drive
I've seen this happening on XP too every now and then, so there's nothing
new in this behavior on Vista. Two ways I usually troubleshoot/workaround
this issue: configuring drive for quick removal and tracking down offending
process.
1. To configure drive for quick removal, Open Device Manager; expand "Disk
drives" node; double click drive in question; on the Policies tab make sure
"Optimize for quick removal" radio-button is checked. This will slow down
file operations on the drive but will allow you to remove it at any moment
without even using (sometimes failing) "Safe Removal" function.
2. Two usual suspects that can keep your USB drive busy are System Restore
and Indexing. I'd check their settings to see if your system configured to
either create restore points for this drive or to index its contents for
instant search. Also, I'd find out exact instance of svchost that has
handles open to this drive and which services are running under this
instance. I use Sysinternals' handle.exe and built-in tasklist.exe
command-line utilities for this. First, you run
handle DRIVE:
to get PIDs of processes that have handles open on the drive. Then you can
run
tasklist /SVC /FI "PID eq PROCESS_ID"
where PROCESS_ID is the PID you've got from handle. If it's svchost that has
handles open, you'll get the list of services that run under this instance
of svchost.
To get friendly names of services, you can use sc.exe built-in utility:
sc qc SERVICE_NAME | find /i "DISPLAY_NAME"
where SERVICE_NAME is the name you've got from taskilst output.
Example:
======================8<========================
C:\>handle H:\
Handle v3.2
Copyright (C) 1997-2006 Mark Russinovich
Sysinternals -
System pid: 4 1C8:
H:\$Extend\$RmMetadata\$TxfLog\$TxfLogContainer00...
System pid: 4 270:
H:\$Extend\$RmMetadata\$TxfLog\$TxfLog.blf
System pid: 4 27C:
H:\$Extend\$RmMetadata\$TxfLog\$TxfLogContainer00...
System pid: 4 288: H:\$Extend\$RmMetadata\$Txf
System pid: 4 368: H:\System Volume
Information\{3808876b-c176-4e48-b7...
System pid: 4 36C: H:\System Volume
Information\{477ccf48-a888-11db-b5...
svchost.exe pid: 1148 5BC: H:\$Extend\$ObjId
svchost.exe pid: 1148 5C4: H:\System Volume Information\tracking.log
C:\>tasklist /SVC /FI "PID eq 1148"
Image Name PID Services
=============== ========= =======================================
svchost.exe 1148 AudioEndpointBuilder, CscService,
EMDMgmt,
hidserv, Netman,
PcaSvc, SysMain,
TabletInputService,
TrkWks, UmRdpService,
UxSms,
WdiSystemHost, WPDBusEnum, wudfsvc
C:\>sc qc AudioEndpointBuilder | find "DISPLAY_NAME"
DISPLAY_NAME : Windows Audio Endpoint Builder
C:\>sc qc CscService | find "DISPLAY_NAME"
DISPLAY_NAME : Offline Files
C:\>sc qc EMDMgmt | find "DISPLAY_NAME"
DISPLAY_NAME : ReadyBoost
C:\bin>
======================8<========================
Re: Vista refuses to safely remove external usb hard drive
This is a known bug in XP that seems to be still present in Vista.
When a save removal is tried Windows can send a message about that
and all processes that hold open but non essential handles should
close them now. But the indexing service doesn't care.
My commandline tool RemoveDrive can prepare a drive for save removal:
Started with parameter -i it stops the indexing service for a moment.
Horrible workaround, but it works...
Sample:
removedrive u: -i
For stopping a service admin previleges are required.
Re: Vista refuses to safely remove external usb hard drive
I'd already rebooted the machine in order to
safely remove the drive by the time I got your message, but I tried your
suggestions just now and the svchost with handles open on the drive has the
services
Windows Audio Endpoint Builder
ReadyBoost
Infrared monitor service
Network Connections
Program Compatibility Assistant Service
Superfetch
Tablet PC Input Service
Distributed Link Tracking Client
Desktop Window Manager Session Manager
Diagnostic System Host
WLAN AutoConfig
Portable Device Enumerator Service
The only services in that list I can think might be using the drive are
readyboost and superfetch. The drive is a regular hard drive, not a flash
drive, so readyboost wouldn't be using it, so that leaves just superfetch.
But I don't know if this current service list is the same as it was
yesterday when I was unable to safely remove the drive, and I can't test now
because I'm using the drive. If I'm again unable to remove the drive the
next time I try, I'll check the services again and post the list.
The drive is not set "Optimize for quick removal" because even if it were I
wouldn't want to remove it without successfully using the "safe removal"
function. Using optimize for quick removal might prevent filesystem
corruption when I just unplug it with no warning, but it won't prevent
potential data loss or other problems with programs which actually have
handles open on the drive for legitimate reasons. I guess I could manually
check the handles every time before yanking the drive but I really want to
be able to use the "safe removal" function as an easy reminder that I might
have forgotten to close some file I had open on the drive.
System Restore is turned off, and indexing is not enabled for this drive.
Re: Vista refuses to safely remove external usb hard drive
Well, depending on TrueCrypt volume size, this may be directly related to
the issue. In my experience most of problems with ejecting USB volumes on XP
were related to working with big files (like ISO images or virtual hard
disks).
At this point I can only guess that this has something to do with write
caching/superfetch when working with big files. Even if you dismount
TrueCrypt volume and close program, there still can be data in cache waiting
to be written down to spindles.
One thing I'd try is sync.exe utility by Mark Russinovich. It forces all
file system data to be flushed to disks, including removable ones.
http://www.microsoft.com/technet/sys...Disk/Sync.mspx
Unfortunately I cannot reproduce the problem at will so I can't say if it
will actually work but I think it worth a try.
And if it doesn't help, I'd still try to turn write caching off on USB disk
in question to see if (1) problem goes away and (2) loss of performance is
tolerable. As I mentioned earlier, you will still be able to use "Safely
Remove" feature, it just will not be mandatory.
1 Attachment(s)
Re: Vista refuses to safely remove external usb hard drive
Vista 64 bit have solution in Microsoft, we can request a fix and it will be send by email for free
I have another interesting tool which should called in cmd as shown in clip_3.jpg below, (my removable drive 500GB transcend is removed successfully only by this tool)
RemoveDrive V1.9.1 - prepares removable drives for safe removal
Freeware by Uwe Sieber -
Works under Windows 2000, XP, Server 2003 and Vista only.
Usage:
RemoveDrive DriveSpec: [-l][-h][-w:nnnn]
DriveSpec: is the drive to remove, e.g. U: or \ for the current drive
[-l] loop until success
[-h] show open handles (admin rights required, exprimental)
[-w:nnnn] wait nnnn milliseconds before close
[-d] show debug information
Re: Vista refuses to safely remove external usb hard drive
Same files open for me. Solved stopping "Windows Search" service for a few seconds.
Uwe Siebers' workaround didn't work for me (it kept retrying to stop the service with no success).
I remember in a similar situation the culprit one of the "Google*" processes, I killed it and the drive could be removed safely. Unfortunately I can't reproduce the situation and I don't remember the exact name so I can't be more specific on this.
As a sidenote, I believe the OS should be able to solve the problem by itself, since this is a serious data integrity issue