From time to time, I cannot safely remove or eject a USB drive. The reason is that one or more processes locks some files. For instance, I observed the following files were locked by a svchost.exe
process on the USB drive F:
,
F:\$Extended$
F:\System Volume Information\
The method that works consistently for me is to use Diskpart
. Note this requires administrative privilege. Below is an example to remove the external drive (shown as Disk 1
),
C:> diskpart
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 465 GB 1024 KB *
Disk 1 Online 1862 GB 0 B
DISKPART> select disk 1
Disk 1 is now the selected disk.
DISKPART> offline disk
DiskPart successfully offlined the selected disk.
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 465 GB 1024 KB *
* Disk 1 Offline 1862 GB 0 B
To bring the disk back online without re-plugging it, we do the steps illustrated in the example below,
C:> diskpart
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 465 GB 1024 KB *
* Disk 1 Offline 1862 GB 0 B
DISKPART> select disk 1
Disk 1 is now the selected disk.
DISKPART> online disk
DiskPart successfully onlined the selected disk.
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 465 GB 1024 KB *
* Disk 1 Online 1862 GB 0 B
DISKPART>