Is it safe to remove USB media when a computer is suspended?

23

3

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)

IQAndreas

Posted 2014-02-16T04:15:33.557

Reputation: 2 317

2

Related, almost a duplicate: Does Windows flush drive caches on standby?

– Ilmari Karonen – 2014-02-16T11:52:48.670

5

...and also Is it safe to disconnect a SATA disk during sleep? and is it safe to unplug a USB drive while Windows is in sleep/hibernate/off mode? The latter one is an exact duplicate, except for being explicitly about Windows, whereas your question doesn't indicate a specific OS.

– Ilmari Karonen – 2014-02-16T12:01:32.120

Answers

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)

kinokijuf

Posted 2014-02-16T04:15:33.557

Reputation: 7 734

5People still use floppies!? – tomasz – 2014-02-16T12:53:19.140

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 – 2014-02-16T13:12:06.920

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: http://www.7tutorials.com/do-you-want-stop-using-safely-remove-hardware-notification-icon

– Corporate Geek – 2014-02-19T16:24:44.927

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 – 2014-02-20T10:25:39.090

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 – 2014-02-20T11:09:58.380

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).

damccull

Posted 2014-02-16T04:15:33.557

Reputation: 111

-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.

Alexander Moon

Posted 2014-02-16T04:15:33.557

Reputation: 1

5Citation needed. – Wyzard – 2014-03-04T22:02:12.447

Agreed. This information is false and misleading – Canadian Luke – 2014-03-05T02:05:37.503

Also, Microsoft writes in "USB Port Remains Active for Disabled or Safely Removed USB Device": "In Windows Vista, Windows Server 2008, Windows 7, and Windows Server 2008 R2, when a USB device is marked as Removed, the USB hub port to which it is connected is not Disabled." So, cutting the power may occur on some OS's, but certainly not on all.

– Arjan – 2014-03-16T09:34:10.037