23

We are often cautioned against unplugging USB drives in case it is currently being read from or written to. When a computer is suspended, hibernated, or asleep is it obviously not writing any data; it may have been in the middle of a read/write, however, it will have put such an operation on hold.

Since no arms are moving (for USB hard-drives), or bytes on the drive flickering on and off (for flash drives), is it then "safe" to unplug a drive?

Is this true even if data is being written to it, but the operation temporarily "suspended"? (assuming you don't mind that specific file only having been half-written to the drive)

9

While there are indeed no transfers going on, the reason you do the Safely Remove Hardware dance is not because of the transfers.

You are doing this to cleanly unmount the file system — programs may be still using the drive, and some files may be still unwritten to the disk even after the application using them is closed. This is the same reason why you don’t just hibernate and switch operating systems — a mounted filesystem is never guaranteed to be in a consistent state.

Ever wondered why the OS slows down to a crawl when using floppies? It is because the cache is flushed after the write of each sector, so the floppy can be removed at any time when not in use.

(Still, you will get a dialog and your program will hang if you try to access a floppy that got removed behind your back. Just insert the floppy back and be done. This won’t work with USB drives because they get a different identifier each time — the program will just crash, and the OS may too if a driver was accessing a file)

  • 5
    People still use floppies!? – tomasz Feb 16 '14 at 12:53
  • 11
    "While there are indeed no transfers going on, the reason you do the Safely Remove Hardware dance is not because of the tranfers." Do you have any sources to support this? It contradicts both Windows's description of the Safely Remove Hardware feature and Microsoft's online documentation. – Marcks Thomas Feb 16 '14 at 13:12
  • 3
    Your answer is incorrect. It is not mandatory to use Safely Remove Hardware, unless you are actively writing files to the removable drive. Read this for a very clear explanation: 7tutorials.com/… – Corporate Geek Feb 19 '14 at 16:24
  • If a program has handles to files open on the drive, the next time it tries to write, it will crash if you yanked the drive off. – kinokijuf Feb 20 '14 at 10:25
  • 1
    @kinokijuf: That would be a bug. Any modern OS will just return an error code to the application, and an application which properly handles error codes will just show an error message to you. "Failed to write H:\thesis.doc" may be a scary message, but it's not a crash. – MSalters Feb 20 '14 at 11:09
1

There are two options in Windows that affect the ability to simply unplug at will. 1) Optimize for fast file writes (technically a lie) by caching on the hard drive before writing to the USB device. 2) optimize for quick removal by ensuring Windows flushes every write to the USB drive immediately.

Back when USB drives were first introduced, you had to use the safely remove hardware feature because the operating system would cache any files you wrote to the hard drive first in order to present a high speed experience. USB 1.0 devices were exceptionally slow. When you click to safely remove hardware the operating system would ensure that it finished copying is local cache to the USB drive before unmounting it.

Web USB 2.0 drives came along they were fast enough to write dukes in nearly real time. Windows preferences changed to default to the USB quick removal option. Since then, if you plug in a USB device and don't manually change the option to cache mode, your drive is already set for quick removal. That means you can take it out as soon as it's stopped writing (light on drive quits flashing).

-4

Unplugging a USB device while the host system computer is live might be dangerous to the USB device. The problem is easily explained, but rarely have I seen a technical reason why this is so. It has to do with the 5VDC power supply to the USB device from the outlet on the host PC. Plugging IN the device is safe enough, but unplugging it is where the problem arises. By suddenly pulling OUT the USB device, the 5VDC current drops abruptly causing a possible collapse of magnetic flux .. and a sudden high-voltage spike that could ZAP the USB device. That high-voltage might be very much higher than the expected 5VDC. So, you have been warned. If you truly value the data on such a USB device, first click on the system tray icon to STOP that particular USB device, which cuts the power to that device before you unplug it safely. If more people realized what was going on, they might tend to be more careful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.