ELI5: Why is it bad to remove a flash drive (or similar) from your computer without 'ejecting' it first?
Posted Dec 1, 2013, 4:08 PM UTC
Posted Dec 1, 2013, 4:08 PM UTC
Because of write-caching.
Caching the writes waits until at least a specific number of writes are in queue (or a certain time has passed) and then writes them all at once. Disconnecting the drive before they are written may mean that a file your OS said was "copied" wasn't entirely written. When writes are cached the drive reports that write requests are complete when they aren't entirely on non-volatile storage quite yet, they are in the volatile cache waiting to be written.
I'm pretty sure by default most flash drives are not write cached. So, unless you are actually writing to it (waiting a for a file copy, etc.) you can remove it without incident. External HDDs are different matter and do write-cache (although you can typically change this in the drive's settings).
This answer is correct. But here it is in ELI5 terms.....
Imagine you've got a line of three robots that wash dishes then hand them to each other and put them away in the cabinet that's across the room. The dish is the information that you're saving and the cabinet is your flash drive. The first robot washes the dish and hands it off. This first robot is the same as what your operating system does when you press save on a file. It prepares it for saving and passes it off to an in-between holding space called the swap space (or page file in windows language). This swap space is the same as your second robot. The swap space is just temporary holding space and makes it much quicker for long term storage to access it. The last robot is the same as a little microchip on the flash drive itself that figures out where there is room to store info on the flash drive and then puts the info wherever there is room.
Now imagine that you unplug the flash drive while it's in the middle of storing a file to the flash drive. That's the same as taking away the robot that's closest to the cabinet. The other two robots aren't going to know that the last robot is missing and are going to keep passing plates off and all of those plates are going to break on the floor.
While the operating system is smart enough to recover from this the flash drive isn't. So if you yank a flash drive in the middle of saving you might end up with corrupted files on the flash drive.
In reality however, this isn't a very common occurrence so most of the time you can pull a flash drive without ejecting it first. If it's an external hard drive though, it is good practice to eject it every time, as those work a little differently.
Technically, you can remove it any-time!
But as you could read that small box, it says to SAFELY REMOVE, meaning the computer will detect if any data-transaction is going on between the computer and the drive. Using this function detects if anything is going on, and if there is it will say UNABLE TO EJECT and if there isn't anything going on, it will inform you SAFE TO EJECT. If there is and you remove it, then there is a chance that the drive might get corrupted due to unbalanced-voltage (they use 5v).
So yeah, thats that.
Because of a trick many operating systems (but most popularly Windows) do to speed up certain actions.
Basically, because USB 1, 2, and even to an extent 3 are very slow compared to other things, Windows does what's called a "Delayed Write"; basically, when a program asks Windows to save a file, it looks at where it's trying to save it to. If it's a particularly slow device, or if the connections to that device are trafficy, Windows reports a success to the application while storing the data somewhere, temporarily. This has the advantage of putting you back into control of your program faster. Windows then writes to the drive at it's own speed, or when the connections are less full. Generally, we're talking maybe fractions of a second, but on slow, old devices, or when you're doing a lot on a particular method of communication, it could take a human-appreciable time to actually do the write. This gives you time to yank out the drive while it's in a state where the file is only partially written. When you "eject" (or "Safely remove hardware", depending on your Windows version), you're basically saying "Hey, Windows. I'm about to yank this bad boy. If you've got any more info to write to it, I'd recommend doing it quickly!". Windows will then make sure to write all the Delayed Write data to the drive (in technically terms, "flushing the write cache").
It could corrupt data.
On a windows computer is makes basically zero difference as long as the files are already copied, but it is still possible that your computer is still doing something with that file (Even if you don't see it) and tampering with that may end up corrupting the data.
Ejecting the device first prevents this.
Actual ELI5: It's just like when you are drawing a picture with crayons and someone sneaks up and pulls the paper out from under your crayon. Your picture is all messed up and you didn't get to finish it.
Windows treat most flash drives as "slow". Instead of writing everything directly to the drive, some data stays in limbo (memory, page file, etc.) until windows think it's the right time to effectively write it on the hardware. So even if you save a word file to your flash drive and word tells you its done, you don't really know what is really going on. Removing your drive might result in corruption as other have already pointed.
[deleted]
I think that if a file is being transferred, and you remove it, the file becomes corrupted which can corrupt your entire flash drive. Ejecting waits until the transfer is complete. But i'm just guessing here.
[deleted]
Your computer might be actively writing to your drive when you pull it out. This can mean that the file being written might not complete, resulting in that file being corrupted and any remaining files being missing, but it can also cause errors to be written to the tables which keep track of the files on the drive, which can make it difficult to recover other, unrelated files as well. Waiting for the computer to unmount the file system ensures that it is done writing when you pull it out.