The task’s simple: you plug in an AHCI-enabled SATA drive on-the-fly, you use it, and then you eject it.
Right? Not so much.
Windows can’t stop your ‘foobar’ device because a program is still using it. Close any programs that might be using the device and then try again later.
On Windows 7 it just worked, and now on WIndows 8 it just doesn’t work. You try to upgrade your chipset driver, your disk controller driver, your whatever driver, but the problem still persists.
The regular answer you’re going to find on the net is that some file is opened from the drive, even though you can reproduce it even if the damn drive doesn’t have ANY file on it at all. So at this point they’ll probably point you to SysInternal’s Process Explorer. You open Process Explorer, set it up to show file paths, and guess what, no damn file’s open from that drive.
Okay, then you dig even deeper, and you might be lucky enough to find another utility called Zentimo Pro. It shows you your drives right away. There’s an option to stop the drive, so you click on it, and voila, it finally tells you where the heck the problem originates from.
So what on Earth does the Task Manager have to do with your disk? Let me show you.
Yup. It’s diskperf, a feature that’s been integrated into Windows 8’s Task Manager, so if you happen to run Task Manager all the time like me, you’re going to run diskperf as well, unless you disable it yourself. So after all, it’s all very simple: if you want to eject your SATA drives on-the-fly, close Task Manager, eject the drive, then restart Task Manager. Mystery solved.