Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have always just unplugged my USB drives from my computer for years and nothing bad has happened; but I heard that you are supposed to use "Safely Remove Hardware" before removing a drive. What does the "Safely Remove Hardware" program do (besides flush the output buffer)?
Is this recommended just to ensure that all data transmission to the device has stopped, or is there another reason?

share|improve this question
    
I also checks to be sure the drive is not in use or being written to. –  Moab Nov 15 '11 at 21:08
    
It does NOT affect the drive itself. It can however affect the files on the drive. This is because as stated before, files are in cache at the time, so when you eject the drive it will write the files to the drive, otherwise you may get corrupted files. –  Matt Nov 17 '11 at 8:44
    
@Matt: Drives have caches too. –  Billy ONeal Nov 17 '11 at 22:38
    
@BillyONeal i never said it didnt :), when i say drive i mean the actual platters, from volatile memory to nonvolatile memory. –  Matt Nov 18 '11 at 7:32
    
@Matt: How on earth is that not affecting the platters? The eject operation flushes buffers onto the platters. –  Billy ONeal Nov 18 '11 at 14:54
add comment

3 Answers

up vote 74 down vote accepted

This depends on what settings you have set for the drive. For instance, if you look in the device manager for the disk drive itself, you'll see something like this:

Device Manager Example

If you have the first option (quick removal) selected, then ejecting the drive merely unmounts the partition, and no longer allows programs to access the drive.

If you choose the second option (better performance), then ejecting the drive flushes any caches the OS has in memory, unmounts the filesystem (which may also flush a few buffers), and flushes on-device buffers.

share|improve this answer
7  
+1 for noting that "it depends" on the config, and including a screenshot –  Lynn Crumbling Nov 15 '11 at 21:32
10  
Thanks - I never knew that option existed. –  LeopardSkinPillBoxHat Nov 16 '11 at 1:52
    
Nice answer! Would you be interested in writing about this briefly for the Super User Blog? If so, let me know in chat or by responding to this comment. –  nhinkle Nov 16 '11 at 5:49
    
This assumes you're using Windows of course... Mac and Linux machines don't have that option AFAIK, but will still complain if you pull out the USB stick before unmounting the drive. –  scottishwildcat Nov 16 '11 at 11:19
1  
@qdot: Most consumer level drives don't do much in the way of write back caching. More enterprisey drives almost always have some form of write-back caching either on the drive or controller. Both types are available as external versions. It's not the USB Mass Storage spec we're talking about here; that same dialog is used for any type of device that can be disconnected; e.g. eSATA, FireWire, IBIS/HSDL, LightPeak, etc. –  Billy ONeal Nov 17 '11 at 17:14
show 8 more comments

The new data is not instantly saved to USB drive, it's stored in RAM for some time. The primary motivation of that appoarch is to gain some performance on pages repeatedly rewritten in place.

So, by unplugging unsafely you have some risk that recently written pages temporarily kept in RAM will never reach the disk.

This may affect not only data, but metadata too - entire directories may disappear, show garbage etc. It's less likely to happen on NTFS, as NTFS has transaction log for the metadata. So on NTFS you just corrupt user data in files and have metadata changes rolled back if you're unlucky on unsafe unplug.

share|improve this answer
4  
NTFS' transaction log ensures consistency of the filesystem. It does not ensure that everything you write to the volume actually gets written. –  Billy ONeal Nov 15 '11 at 21:18
1  
It works the other way too. If data if being copied to the computer form an HDD, then it may have been scheduled for delayed transfer. In that case, the data will appear on the destination drive but if the host is unplugged, the destination data will disappear. –  AndrejaKo Nov 15 '11 at 21:24
    
Also, the delay in writing to the drive tries to minimise total writes - lengthening drive lifetime. –  DefenestrationDay Nov 16 '11 at 4:18
    
@CapsicumDreams: Perhaps for solid state drives that's true. Conventional magnetic storage doesn't have a write count limit. (Well at least not in the "reasonably small enough that someone might hit the limit" territory) –  Billy ONeal Nov 17 '11 at 21:17
add comment

Exactly, this is all this does. It flushes all buffers and ensures nothing can access the USB drive anymore by disconnecting it from the system.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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