Quick answer for the impatient
Open Command Prompt as admin, run diskpart, then list disk, select disk X (replace X with your drive number), clean, then create partition primary and format fs=ntfs quick. This wipes everything and forces the format. But read on — there's a smoother way that keeps your data if you need it.
Why this happens
Windows refuses to format a drive because some program or system process is holding the volume open. This can be as dumb as a File Explorer window pointing to that drive, or as sneaky as a background antivirus scan or a backup tool. I've seen this on a client's external drive last month — they had a Dropbox folder syncing to it, and Windows just wouldn't let go. The error usually pops up in Disk Management as a grayed-out Format option or a message saying "The operation failed because the volume is in use." Sometimes it's a phantom lock from a crashed program too.
Fix steps (start here)
- Close everything. Sounds basic, but close all File Explorer windows, programs, and especially anything that might access the drive — like media players, backup software, or cloud sync apps. Check the system tray for hidden icons.
- Run Disk Management as admin. Press Win + X, click "Disk Management". Right-click the volume, choose "Format". If it works, done. If the option is grayed or you get the error, move on.
- Use Diskpart to force it. Open Command Prompt as admin (search cmd, right-click, run as admin). Type
diskpart, press Enter. Then:
Replace X with the correct disk number fromlist disk select disk X clean create partition primary format fs=ntfs quick assign letter=Ylist disk. Warning: This erases all data on the drive completely — no recovery. Thecleancommand removes the partition table, so the format goes through without the "in use" error. - If Diskpart still fails (unlikely but possible), the drive might have a hardware lock. Try a different USB port or a different PC. Some external drives have a physical write-protect switch — check for that.
Alternative fixes if the main one fails
If you can't use Diskpart because you need to keep the data (like formatting a system partition while Windows is running), then you need to find the culprit process. Here's what I do:
- Use Process Explorer (from Microsoft Sysinternals). Open it, press Ctrl + F, type the drive letter (like E:), and it shows which process has a handle to it. Kill that process, then format. Real example: I once found a stuck Windows Search indexer locking a USB drive — killed it, format worked instantly.
- Boot from a USB or DVD. If the drive is your main system drive, you can't format it while Windows is running. Use a Windows installation media to boot, press Shift + F10 for Command Prompt, then run Diskpart there. This bypasses all locks.
- Try third-party tools like GParted (boot from a Linux live USB). It ignores Windows locks and formats directly. But that's overkill for most people — only do it if Diskpart on a bootable USB fails.
Prevention tip
To avoid this in the future, always properly eject external drives after use. Go to the system tray, click the USB icon, and select "Eject". Also, don't let apps like antivirus or backup software run unattended on removable drives — schedule them for when you're not using the drive. And if you're like me, keep a habit of closing all File Explorer windows before trying to format. It takes two seconds and saves you a headache.
One more thing: if you're formatting an internal drive that's not your system drive, make sure no virtual memory (pagefile) or System Restore points are using it. Check in System Properties -> Advanced -> Performance -> Advanced -> Virtual Memory. If it's assigned to that drive, move it to another drive or disable it temporarily.