Does Safely Ejecting From a USB Port Actually Do Anything?

Is there any harm to be incurred by just pulling a flash drive out? Why do we need safe removal at all?

Historically, Operating Systems treat disks as objects that can be trusted not to change state suddenly. When reading or writing files, the OS expects the files to remain accessible and not suddenly disappear in mid-read or mid-write.

If a file is open, a program reading the file expects to be able to return to it and continue reading. Similarly, write commands may be dispatched to a writing subroutine and forgotten by the main program. If a drive disappears between the time the subroutine is called and the data is written to disk, that data is lost forever.

In ye olde days, there were formal processes to physically “mount” and “unmount” storage media, and the physical act of mounting a tape or a disk pack triggered some mechanical switch to detect the presence or absence of media. Once the mechanism was engaged, the software could start to use the media (a “soft mount.”). Some media even had mechanical interlock to prevent media from being ejected or removed until the software processes using the media released the lock.

The Macintosh floppy and optical disk provide more modern examples of an interlocked physical and soft mount. One could only eject media through a software command, but that command might fail if some program was holding a file open on the medium. Enter USB connected storage. There is no mechanical interlock in a USB connection to coordinate the hard and soft mount. The user can decide to rip the disk out from under the operating system at any time, and endure all manner of programs freaking out about the sudden loss of media. “Hey! I was using that!”

Symptoms could include: Lost data, corrupted filesystems, crashing programs, or hanging computers requiring a reboot. A safe removal executes the “soft unmount” needed to prevent any unexpected Bad Things that may happen if a program loses its access to media.

A safe removal does a few things:

It flushes all active writes to disk.

It alerts all programs (that know how to be alerted) that the disk is going away, and to take appropriate action.

It alerts the user when programs have failed to take action, and still are holding files open.

You can remove a disk at any time, but you are at the mercy of how well programs using the disk cope with the sudden disappearance of that disk.

In the modern computer, many steps have been taken to defend against the capricious and careless removal of media. For example, Windows even introduced a feature called “Optimize for Quick Removal” that makes sure data is written quickly instead of batched up and written efficiently. It is very hard to get people to change habits. If you are doing exclusively reads on a media, safe removal is probably not needed. If you are doing writes, you are probably OK to skip safe removal if you haven’t written recently and you aren’t doing something silly like indexing that disk.

As a good friend of mine once said: Life is too short to safely eject the disk.

However, Safe Removal does a number of important things and is, in fact, the only assuredly safe way to remove a disk. You probably don’t need it most of the time, but it is a good habit to have since data loss sucks.

via Does Safely Ejecting From a USB Port Actually Do Anything?.

Advertisements

About steventorresramos

I have over (24) years of Computer Aided Drafting & Design experience and over (16) years of IT experience. After graduating high school I attended a Technical College and earned an Associate Degree in Drafting & Design. I then enrolled at the University of Puerto Rico where I earned an A.S. in Civil Engineering Technologies. While attending the Univ. of Puerto Rico I worked as a freelance Drafter for a variety of architects and engineers. During my senior year I began to work for the firm Planning Management & Development in Ponce, Puerto Rico. Two years later I was offered the position at Mario Corsino & Associates, which later became InterGroup a medium size Civil Engineering, Architectural and Planning firm in Bayamon, Puerto Rico. At InterGroup I became assistant chief drafter where I was responsible for 20+ drafters & civil techs, and this is also where I began my IT training. In 2000 I decided to move to St. Petersburg, FL where I was hired as CAD Manager at Advanced Engineering & Design a small Civil Engineering firm established in 1998. Currently still employed by Advanced Engineering & Design I’m now the CAD/IT Manager. I have also continued to expand my knowledge base in both the IT & CADD fields through continued training, certifications, and attending Autodesk University. I’m currently an Autodesk Certified Professional proficient in AutoCAD, Civil 3D and various other Autodesk products. I have been the President of the Tampa Bay Autodesk Users Group (TBAUG) since late 2007 and a member of Autodesk Users Group International (AUGI) since 1996. I have an A.S. Degree in Computer Networking , a Bachelors of Applied Science in Technology Management and currently finishing work on my Masters in Computer Information Systems. I’m a licensed drafter in the US Commonwealth of Puerto Rico, and a Microsoft Certified Professional. I hold certificates as a Microsoft Certified IT Professional: Server Administrator, Cisco Networking Associate Professional and Linux Administrator.
This entry was posted in Interesting, Tech, tips. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s