USB - more everyday
Unplugging USB
"Do you need to 'Safely Remove Hardware'?"
tl;dr:
- depends on the driver
- depends on the device
- mostly it's fine, though it's not a guarantee, and a few specific things can cause issues
- if it involves storage, you may break off in the middle of a write.
For the USB bus itself, it's fine.
USB was made to be hot-pluggable.
Nothing will spark, and the host will almost certainly figure out a device left.
That says nothing about the function.
- If the driver was not considering the possibility of a device leaving, that may cause trouble.
- this is rare; it's part of the USB SDK to handle this
- If an application was not considering the possibility of a device leaving, that may cause trouble.
- many APIs (video, audio, whatnot) also include devices leaving. It's something you ought to handle, but some programs do not.
The real question is what the thing on top is doing.
- If this is a keyboard, mouse, webcam, MIDI interface, the data isn't as important as the fact that the device is no longer there to be used
- If the thing the device was doing involved storage, there is a chance you broke off in the middle of writing
- and that may leave that storage in a bad state
- (with some minor footnotes, such as that standard USB storage / video / HID class are more of a know quantity than drivers for custom hardware that to you has the same function)
For storage
For a sound card, webcam, keyboard or mouse or such, you won't care to completely lose the packets it's currently transferring.
For storage, on the other hand, you usually will - anything from a USB stick, memory card, external hard drive, connected cameras in storage mode.
Disconnecting a drive while running originally previously wasn't a thing, so filesystem APIs assume that a file stays open and available until the program that opened it says it is done.
Yanking while reading from a external storage will almost certainly make the reading program unhappy,
yet the storage itself is typically fine.
Yanking while writing is usually bad.
- Most filesystems write file data in-place (meaning they do not implement a guaranteed recovery)
- A number of filesystems are a little more robust about filesystem metadata - but you shouldn't assume it
There is a common optimization in "keep the last seconds worth of data before actually writing it" (see writeback versus writethrough).
This optimization is usually disabled for USB-connected storage - except when it's not.
Also, certain kinds of storage (non-ssd flash) erases a block before rewriting it,
so there is a time at which only the host knows the data.
So you can expect USB flash sticks to corrupts a little more easily while writing (SSDs, while based on Flash as well, have a more complex, smarter controller that avoids at part of that issue and should be more recoverable).
USB Device Not Recognized / Device has malfunctioned
Shown in a balloon near the task bar, with the addition that "One of the USB devices attached to this computer has malfunctioned, and windows does not recognize it."
(In some cases, if the balloon message is disabled, the device only shows up as an "Unknown Device" in the device manager.)(verify)
My summary so far is that there are many possible causes, it's hard to say which one it is, and most solutions are not very clearly good ones. Reinstalling usually won't help.
Possible problems/solutions
Things you can check easily enough:
- broken device
- test: try in other computers - and to be sure, also with varying OSes (some devices don't have drivers for older/specific OSes)
- broken cable (cables get stepped, yanked, etc.)
- if it's interchangeable, try another one.
- If it's not interchangeable, try wiggling it to see if it accidentally makes a good contact. It's not a very good test in that it not working means nothing, but if it turns up temporarily, you know that a bit of DIYing may well fix the problem.
- broken USB socket
- Test: Try other things in the same port, and try this device in other ports
- Note: each pair of ports is usually the same internal hub, so only trying the one right next to it is not the best test.
- Basic mice are the most useful test devices, as they are low-power and do not require drivers to work
- USB port in a weird state (e.g. the previous device drew too much power and triggered the polyfuse. But there is another reason or two)
- (some are more sensitive/careful than others. Macbook polyfuses were apparently known for triggering quickly)
- Test/fix: Turn computer off completely, and then leave the power cord/battery out for a few minutes (that much is rarely necessary, but sometimes it is and it takes less time to wait a bit longer once than to reboot again)
- USB knows you are crossing the limit of power it can give out, and refuses the next device
- more likely to happen on a non-powered hub
- Test: try plugging the device into the computer itself (or into a powered hub that has no high-powered devices)
- Front ports may sometimes be non-powered hubs, so a back (motherboard) port may be a better test.
- Test: try a mouse in the same port - it's low-power and so very likely to work if the port's not broken.
Harder to check well:
- stupid/missing driver for the particular device
- Test: Try again after a restart, try with different OS, try with a different driver,
- stupid power management bug (happens on some hardware)
- There is/was a bug in XP(/Vista?) where power-suspended USB ports are not re-enabled properly, and there were mixed reports about Microsoft's patches (verify). Some people report that disable this port suspending feature helps.
- windows USB driver set/setup got wonky.
- Bit of a last resort thing to check
- Test/fix: Uninstall as many related drivers as you can before plugging the devices back in.
- some devices don't like sleep/hibernate, regardless of version of anything
- and may stay confused until a reboot
It seems that certain devices are likelier to trigger this problem.
It seems that Windows's collection of drivers for USB devices (one or more) can get wonky.
It may be that reinstalling all of these can help.
Remove controllers drives last, so peripherals drivers first.
Then rebooting and let it re-detect and re-install everything.
See also
- http://dan.hersam.com/2005/07/18/usb-device-not-recognized/
- http://support.microsoft.com/default.aspx?scid=kb;en-us;817900
- http://support.microsoft.com/?kbid=873169