CLOSE
iStock
iStock

Does Safely Ejecting From a USB Port Actually Do Anything?

iStock
iStock

Does safely ejecting from a USB port actually do anything?

Phillip Remaker:

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 (OS) 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 file systems, 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 introduced a feature called "Optimize for Quick Removal," which 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.

This post originally appeared on Quora. Click here to view.

nextArticle.image_alt|e
arrow
History
The Queen of Code: Remembering Grace Hopper
By Lynn Gilbert, CC BY-SA 4.0, Wikimedia Commons

Grace Hopper was a computing pioneer. She coined the term "computer bug" after finding a moth stuck inside Harvard's Mark II computer in 1947 (which in turn led to the term "debug," meaning solving problems in computer code). She did the foundational work that led to the COBOL programming language, used in mission-critical computing systems for decades (including today). She worked in World War II using very early computers to help end the war. When she retired from the U.S. Navy at age 79, she was the oldest active-duty commissioned officer in the service. Hopper, who was born on this day in 1906, is a hero of computing and a brilliant role model, but not many people know her story.

In this short documentary from FiveThirtyEight, directed by Gillian Jacobs, we learned about Grace Hopper from several biographers, archival photographs, and footage of her speaking in her later years. If you've never heard of Grace Hopper, or you're even vaguely interested in the history of computing or women in computing, this is a must-watch:

nextArticle.image_alt|e
Google
arrow
Animals
Watch Christmas Island’s Annual Crab Migration on Google Street View
Google
Google

Every year, the 45 million or so red crabs on the remote Australian territory of Christmas Island migrate en masse from their forest burrows down to the ocean to mate, and so the female crabs can release their eggs into the sea to hatch. The migration starts during the fall, and the number of crabs on the beach often peaks in December. This year, you don’t have to be on Christmas Island to witness the spectacular crustacean event, as New Atlas reports. You can see it on Google Street View.

Watching the sheer density of crabs scuttling across roads, boardwalks, and beaches is a rare visual treat. According to the Google blog, this year’s crabtacular finale is forecasted for December 16, and Parks Australia crab expert Alasdair Grigg will be there with the Street View Trekker to capture it. That is likely to be the day when crab populations on the beaches will be at their peak, giving you the best view of the action.

Crabs scuttle across the forest floor while a man with a Google Street View Trekker walks behind them.
Google

Google Street View is already a repository for a number of armchair travel experiences. You can digitally explore remote locations in Antarctica, recreations of ancient cities, and even the International Space Station. You can essentially see the whole world without ever logging off your computer.

Sadly, because Street View isn’t live, you won’t be able to see the migration as it happens. The image collection won’t be available until sometime in early 2018. But it’ll be worth the wait, we promise. For a sneak preview, watch Parks Australia’s video of the 2012 event here.

[h/t New Atlas]

SECTIONS

arrow
LIVE SMARTER
More from mental floss studios