why is there a “safe to eject” option for USB sticks?

488 views

After you’ve transfered all your data on/off, why cant you simply take out the stick? where’s the harm?

In: 252

30 Answers

Anonymous 0 Comments

The “safely eject” option is just checking to ensure nothing is reading from/writing to the device. The user may not be aware of everything using the device.

Anonymous 0 Comments

Most modern operating systems employ file system caches to speed up reading/writing data from/to storage volumes. If you just yank the drive, then the system does not have an opportunity to write any unwritten data sitting in the cache to the volume before it is unmounted.

Hence, file system corruption is a very real possibility if you don’t advise the system that you’re done with the volume.

Anonymous 0 Comments

If you just use the stick as a storage drawer for random files and nothing else, there’s basically no harm in just ripping it out.

The feature is there in situations where you actually have a running program actively using a file that lives on the USB stick. Like, if you had installed a program on the USB stick and it was running, and you ripped out the stick, the program would probably stop operating correctly and you might corrupt a whole ton of files. That wouldn’t be good.

What the “safe eject” feature does is it checks to see if any programs are currently using the stick. If there are, it will attempt to tell them to stop. If they refuse, it tells you about them. Once all programs are shut down, the stick is set to “Closed” so no programs can use it anymore, and you get the message that it’s safe to remove.

Anonymous 0 Comments

I see the answer has already been given. Just going to add that since usb sticks have been invented, not once have I ever done the “safe to eject” option and nothing bad has ever happened.

And I know someone is going to comment “you could corrupt your files!!!”

So in advance, great. thanks.

Anonymous 0 Comments

For performance reasons, computers use layers of caching* to minimize writes. The “eject” option will ensure those caches get fully flushed before telling you it is safe. If you unplug the device randomly, those caches may not be written, resulting in data corruption on the disk. Depending on the nature of the corruption, this may only affect a small number of files, or, in very rare cases, it may make the entire disk unreadable.

This same process applies for the main disk drives in your computer as well, however you don’t normally remove them while the computer is running. A full system shutdown will also make the USB stick safe to remove.

* If you care, you typically have three layers: application, operating system (OS), and drive. Its not uncommon for an application to have two or three caches itself, and the OS driver may have an additional one between the OS and drive, on top of the OS’s primary one.

Anonymous 0 Comments

[removed]

Anonymous 0 Comments

While the other comments are right but the safe ejection option is far less needed now than it used to be. The safe eject option was necessary in the past because back in the day the file systems on the disks weren’t journaling. Without the ability to track pending changes via journaling it was actually possible to corrupt the entire drive if you pulled it at the wrong time.

Anonymous 0 Comments

compared to the system memory in your computer, a USB stick is glaciouslly slow by several orders of magnitude. To help the user work faster and provide the appearance of speed, the system will write the data to a buffer in its memory. This is basically a tall tower that data is piled ontop of.

Over time, the system will take the bottom of the stack and write it onto the USB stick in whats called a flush operation. This will happen at various speeds depending on what your doing with the drive. If your constantly reading/writing files off of the drive, the system will try and optimize the workload by keeping it all in memory and only flushing content that stopped being touched. If your just copying files onto the drive, the system may try and flush that buffer as quickly as possible because its expected that your probably going to remove it after your done.

If you remove the USB stick while there is still a buffer of data that needs to be written, it will never make it to the USB drive. This will result in corrupted files like videos that dont play, text files with missing content, files that dont read, etc.

When you tell them system you want to safely eject, it will go through those buffers and flush it out as fast as possible so all the files are actually where you requested them to be.

Anonymous 0 Comments

I think I can put this in simple terms.

Imagine a binder with many pages. The first page is the table of contents. Any time you need to add or remove a page from the binder, the table of contents needs to be adjusted. Except no page can be altered except when taken out of the binder.

So if you slam the binder closed and take it away while a page isn’t inside, that page will be missing. And worse, if you do this while the table of contents is out, you can destroy the record of everything in the binder. A computer *has* to look at a table of contents to find files. Some fancy recovery programs are made to basically flip through the binder trying to recognize information, but it may not be successful.

So the “Click to Eject” option is you asking the computer? “Hey, are you done with this?” At which point it will confirm all the pages are inside, close the binder, and give it to you.

Anonymous 0 Comments

ELI5 format:

Imagine you have a truck pulled up to a loading dock, and people come by with things to put into it.

Each time you go up to the dock and hand something (you write a file, say) to the person there (the operating system), they have to drop everything, run into the truck, and place your item there.

That’s really slow, right?

So the person just puts those things into a little pile by her side, waiting for enough people to drop enough things off so that she can save time by going to the truck just once to drop off the whole load.

Which is great – now you can have a long line of people drop off little things quickly, and they don’t have to wait after each drop off until the person goes to the truck and returns.

But now imagine – it’s time for the truck to leave with its load. If it just pulls away from the dock, it’ll leave a bunch of things behind. So a bunch of stuff is lost. Worse, someone may have dropped off 10 items together, but on the last loading trip to the truck, you could only take 3 of those things to the truck (because your hands were full). So now, when the truck pulls away, your delivery has been mangled.

So, you want the truck driver (the flash disk) to send a signal to the person (the operating system) saying “I’m about to leave, yo”. And the operating system hustles and writes everything back on to the disk, and then says “It’s OK to leave/unplug now”.