49

Sometimes when I try to remove an external USB hard drive I get the message:

Windows can't stop your 'Generic volume' device because a program is still using it.

I tried closing all programs on the Desktop, but it still won't give the "safe to remove" message. I am generally able to make flash drives safe to remove without a problem.

How to safely remove a USB drive when I get this message?

I have Windows XP and Vista if that matters.

6
  • 5
    Sleep the box, remove the drive once the box is asleep. Commented Apr 11, 2014 at 11:44
  • 7
    Still a daily problem on Windows 10 Pro (1703, 15063.413, x64). Commented Sep 16, 2017 at 23:56
  • 2
    Windows 10 1809, still the same.... Why don't they just write WHICH program is using it....
    – Yvon
    Commented Mar 27, 2019 at 23:33
  • 1
    Related: Can Windows tell me what is using my USB drive?
    – krubo
    Commented May 31, 2019 at 12:35
  • close the task manager if it is open. the thing that opens with ctrl+shift+esc. Commented Sep 25, 2023 at 7:42

21 Answers 21

21

Look for RemoveDrive on this page (direct link to the Drive Tools page RemoveDrive tool section).
Those pages also have good related information.

The RemoveDrive tool is useful also when
you Do not get ‘Safely remove’ option in Tray for USB storage devices.

5
  • Anything that can tell you what is holding the drive is good. I've gotten this after I closed everything, all explorer windows even. So sometimes Windows just doesn't want to let the drive go. Commented Sep 6, 2009 at 18:21
  • @Joshua, I have felt that sometimes Windows is Indexing the drive and holds it for that... The "-i" option on RemoveDrive disables the indexing service for a moment to remove the drive.
    – nik
    Commented Sep 6, 2009 at 18:22
  • I like Unlocker which is dedicated to the task of displaying and freeing open file/directory handles.
    – opello
    Commented Sep 6, 2009 at 18:24
  • 1
    Re unlocker: Note that this is dangerous. You will be able to remove your pen drive but you risk corrupting future files when a file handle gets recycled and both the new and the old program try to write data to it.
    – Hennes
    Commented Aug 15, 2014 at 21:39
  • 1
    Relevant article on technet which talks about closing file handles for deletion, but the same holds in the pendrive case.
    – Hennes
    Commented Aug 15, 2014 at 21:50
9

Often this will be because the drive is being indexed; right click the drive>properties, and uncheck index. Or the AV is monitoring the drive - turn off AV to test this.

1
  • Thanks, but wtf? What is this "indexing"? And why doesn't Windows just pause any indexing when you click "eject"?
    – krubo
    Commented May 31, 2019 at 12:31
7
  • Right click on the properties of the USB drive in Windows Explorer.
  • In the popup window click on "Hardware".
  • Identify the drive and left click on it once to highlight it, then click the properties box.
  • Click on "Change settings".
  • Click on the Policies tab and select "Optimize for quick removal" and click OK.

If you're sure that none of your own processes are still in use on this USB just pull it out.

[Edit: Not found official Microsoft documentation of this method, but Cnet has an article about it: Quickly remove USB devices without using Safe Removal .]

1
  • 2
    This method is so much better than all the rigamarole of the higher-rated answers.
    – NewSites
    Commented Jan 25, 2018 at 4:23
6

There are several reasons to USB being undismountable:

  1. It's in use. Please note that if you're looking at the disk in Explorer, then it's in use!
  2. Windows is finishing copying a big file to or from the disk (rarely the reason)
  3. A bug in Windows causes conime.exe to get stuck on the disk (it may safely be killed)
  4. If the USB drive is formatted as NTFS, the journal of all file updates may still be open
  5. If disk indexing is on for the drive, Windows may be furiously indexing all files on it

My advice is to:

  1. Make sure the USB drive is not defined as indexed.
  2. Wait, and then try again. It might work a few seconds later on.
  3. Buy Zentimo ($29.90) that does a good job of trying to remove the disk. Even if it fails, it still tells you which programs are using what files (I paid).
2
  • would deleteting a large amount of data cause this problem? I deleted about 1TB of data, and it looks like the process completed, but the drive will not eject safely.
    – derelict
    Commented Oct 2, 2015 at 18:00
  • @SoilSciGuy: If none of the above points works for you, use the free Process Explorer to search for "X:" (X=disk) to see if it's being used.
    – harrymc
    Commented Oct 2, 2015 at 19:05
5

I found the free USB Disk Ejector to be very useful:

A program that allows you to quickly remove drives in Windows. It can eject USB disks, Firewire disks and memory cards. It is a quick, flexible, portable alternative to using Windows’ “Safely Remove Hardware” dialog.

2
  • 1
    Looks like a great app, but did not work for me. Commented Jul 20, 2016 at 21:15
  • Still getting a 'The disk could not be ejected. Close any programs that might be using the disk and try again.' error message with this software. Commented Oct 20, 2020 at 8:58
5

Quick Way to Find Process/File Open that is Preventing Unmount:

I just figured this out. With Process Explorer (free download) this is really easy.

  1. Download, unzip and run procexp.exe
  2. Choose from the "Find" menu, "Find Handle or DLL..." or hit Cntl-F
  3. Enter only the drive letter (followed by ":\") in the search text box

This will show you all the open files on your removable volume, the processes that own the file handle and the PIDs of the processes. Double click to highlight the process in the main window (top) and file (bottom). From there you can right-click the process to kill it or right-click the file to close the file handle.

2
  • 2
    Upvoted because this tip was pretty cool. Unfortunately, I'm still stuck. I found that explorer.exe was the culprit. I restarted explorer.exe and then did the search again, which resulted in "0 matching items". But I still get the error message "Windows is unable to stop the device...".
    – Ryan
    Commented Jan 7, 2017 at 15:40
  • 2
    In my case it says that only "System" is holding the reference.
    – TN.
    Commented Jan 1, 2018 at 22:47
4

This is by no means a good answer, but you can always shut down the computer and remove the USB device.

4
  • 2
    Actually you can't! You'll hear the drive click. But if it's ejected the click doesn't happen. I don't know if that matters, but I've had problems with two external hard-drives (drive appeared unformatted), I suspect it was because of such shutdowns...
    – Alex
    Commented Oct 9, 2013 at 2:24
  • @Alex If you shut a computer down, it can't be using a drive if it doesn't have any power. Commented Nov 2, 2014 at 14:49
  • Shutting down the system was my solution until chkdsk started finding errors after doing that. Commented Jul 20, 2016 at 21:17
  • 3
    @RockPaperLizard Then there's something wrong with the software. The OS told the program that it's shutting down, it still didn't flush writes and close the file. There's nothing you can do at that point besides smack the developer on the head.
    – davidtgq
    Commented Jan 7, 2017 at 16:20
4

If it's none of the pedestrian/common options, it could be you have the drive listed as 'shared' on a network and have accessed it via another computer. In my case, even though the remote computer was off, it still had a lock on the directories. Unshare and it should work if that's the case.

3

The System, usually, is not the culprit in this case. $TxfLogContainer00000000000000000002 and other NTFS log handles are not, in fact, the reason for this problem. Sysinternals Process Explorer will usually fail to notice handles opened by background processes that actually block the drive. Or there might be no handles opened at all, yet still the process can block the USB drive.

To find out what process is the actual culprit do this:

  1. Press WIN + R
  2. Launch eventvwr.msc
  3. Open Windows Logs -> System
  4. Examine latest warnings that state The application ... with process id x stopped the removal or ejection for the device USB ...

enter image description here

You will probably find System in there, but again, you can only suspect the System if it is the only one among this warnings. In my case, the actual culprit was LightingService.exe process. It is a part of ASUS AURA RGB lightning control software. I have no idea why it was blocking the drive. The disk had 0 write/read activity, but it was still spinning constantly without stopping. Maybe it tried to control the "RGB" on the drive? It seems that other people had the same problem, so this is a critical bug in a driver software that was never fixed.

The irony in this story, is, that I was blaming Windows for this bug all along. But it turned out, faulty 3rd party software was the culprit. Bizarre.

2

Simple fix (Windows 7 Professional 64-bit):

  1. Change the drive letter, and if you want to keep the same letter, change it back.

  2. The drive can now be unmounted.

When you change the drive letter, it disconnects the drive from all processes that might be using it, as the warning message states. Once that happens, you can then unmount it the usual way.

If you don't know how to change drive letter, follow these instructions.

  1. Control Panel --> Administrative Tools --> Computer Management --> Storage --> Disk Management (wait ~10 seconds for information to appear.)

  2. Select the problem drive under volume heading.

  3. Scroll to that drive in the lower part of window.

  4. Right-click on the drive, and select Change Drive Letter and Paths.

  5. Change the drive letter to one not reserved for another drive.

  6. Acknowledge the warning message.

If you wish the drive to retain the original letter, simply switch it back. The drive can now be unmounted.

1
  • Just so you know, that particular answer has been cited on a blog post : cybertext.wordpress.com/2017/02/22/… – for that reason alone it deserves an up vote. But unfortunately, I just tested this method with a stubbornly locked USB HDD, it doesn't work when the “System” process is the culprit (I get this regularly, and neither ProcessExplorer nor LockHunter can close the handles associated with four system files in \$Extend\$RmMetadata\, and changing the drive's letter results in the same handles reappearing just a second later with the new letter).
    – GabrielB
    Commented Dec 7, 2017 at 14:58
2

I think this is because Windows itself is still finalising the writes to the hard drive. I get the same message if I try to disconnect straight after copying some files. If I wait until the drive has stopped spinning then it disconnects without any problem.

0
2

I disabled write caching on the USB device. Now it ejects perfectly fine.

Disable write caching on the USB device

Steps:

  1. Win+R, type diskmgmt.msc and run it
  2. Right click USB device -> Hardware tab -> Click properties
  3. Policies tab -> Uncheck "Enable write caching on the device"

It says enabling this causes data loss or corruption where there's power outage or equipment failure. So I prefer it disabled.

3
  • 2
    Note that this method may slow down I/O operations with the USB device.
    – Kitswas
    Commented Jul 15, 2021 at 14:48
  • I thought this was a good Idea, but it really slows down the write operations. For example, my external hdd write-speed dropped to 30Mbps from 110Mbps. so this answer is more of what not to do if you care about write speed.
    – Pavan
    Commented Jul 21, 2021 at 12:38
  • I've found out that disabling real time protection from Windows Defender anti virus works. I re-enable it after ejecting. I think the anti virus is watching the drive for sure. This works consistently. I'm happy with it although it shouldn't be like this. Windows security -> Virus & threat protection -> manage settings -> Real time protection
    – Pavan
    Commented Jan 17, 2023 at 3:38
0

Take a look for programs installed recently, which can prevent safe HDD disconnection.

In my case it was Magical Defrag 2: any newly connected disk with new letter assigned was automatically marked, so now after unmark I can safely remove the USB drive.

0

The 2 most reliable ways are ones that nobody has suggested yet because they are sometimes the most inconvenient:

  1. Log off. Log back on. Try again to safely eject the USB device (via the Windows tool). If even that didn't work, then:
  2. Shut down your computer entirely. Then simply unplug the USB device without asking permission.
0

For me changing the drive letter did it. I could not kill the accessing process cause it was PID 4 (system itself), which opened H:\$EXTEND..... (did see it in Process Explorer).

After changing the drive letter i could savely remove it..... WOW, Windows is a never ending adventure game..... :))))

-1

This is due to the fact that there is at least a process/program that is still accessing your USB drive. It may not be enough if you just close all the programs on dekstop, if you are copying folders from/to the USB hard disk, you will get this message.

Try and find what process is holding the resource and either complete or close the process and you should be able to remove the USB hard disk without any problems.

Do let us know how it goes.

-1

Try hotswap free utility, you can download here http://mt-naka.com/hotswap/index_enu.htm.

  • Ensure to activate Safely removable devices by right click the icon hotswap on systray - device type - Safely removable devices.
  • Then you can remove USB drive by left click icon hotswap on systray and select your removable drive.
0
-1

this method worked to me 1) : Run -> "diskmgmt.msc" -> Find your drive in the physical disk list (bottom pane) -> right-click the drive (the left-most part), not the partition -> Click "Offline"

2) : Run -> "cmd.exe" -> type "diskpart" -> type "list disk", find your disk # -> type "select disk x", where x is your disk's # from the last step -> type "offline disk". Now you can exit the command prompt or just type "exit" at diskpart, then close the prompt."

I use "remove all dismount" on the diskpart command to kick the disk out. can't make it simpler now as Devcon command couldn't kill the disk out soon either.

now use the safely remove hardware and eject media tool

Thanks to

Reizaal Abdul Aziz

https://answers.microsoft.com/en-us/profile/bf1a3358-a39a-4c32-bc7e-692576439363

1
  • Welcome to Super User. It looks like you are trying to provide attribution. Just "advertising" a stranger isn't a useful way to do that. Instead, link to the source of the information.
    – fixer1234
    Commented Feb 12, 2018 at 0:38
-1

Thank you all for this windows problem that many have problems with, this is my answer to it. Easy : not click the safe remove icon on taskbar but goto the USB stick in explorer and Eject there, Solved.

1
  • Welcome to Super User. Since the OP specified that they want to safely remove the drive (i.e. remove it without the risk of data loss), this does not answer the question, since to do this does NOT ensure no data loss upon removal. Commented Dec 17, 2018 at 22:52
-1

This worked for me:

  1. Open task manager
  2. Go to the Details tab and close explorer.exe (it will close all your opened folders)
  3. In the task manager press File->New-> type explorer.exe to bring it back and then try right click on the USB picture and press eject:
    enter image description here
1
  • This changes the order of open windows in the taskbar.
    – root
    Commented May 4 at 6:58
-2

I've noticed this a lot. What we do is to share and then unshare the drive. It's had a 99% success rate. I have no clue why it works, but time to time it says another user is accessing the drive... even though I just shared it only to unshare it. Try that. You'd be surprised at the success rate.

1
  • 1
    This tip unfortunately hasn't worked for me with my external Backblaze hard drive on Windows 10.
    – Ryan
    Commented Jan 7, 2017 at 15:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .