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
iStock
Undersea Internet Cables Could Be Key to the Future of Earthquake Detection
iStock
iStock

Considering that 70 percent of the planet is covered by oceans, we don't have all that many underwater earthquake sensors. Though there's plenty of seismic activity that happens out in the middle of the ocean, most detection equipment is located on land, with the exception of a few offshore sensor projects in Japan, the U.S., and Canada.

To get better earthquake data for tremors and quakes that happen far from existing sensors, a group of scientists in the UK, Italy, and Malta suggest turning to the internet. As Science News reports, the fiber-optic cables already laid down to carry communication between continents could be repurposed as seismic sensors with the help of lasers.

The new study, detailed in a recent issue of Science, proposes beaming a laser into one end of the optical fiber, then measuring how that light changes. When the cable is disturbed by seismic shaking, the light will change.

This method, which the researchers tested during earthquakes in Italy, New Zealand, Japan, and Mexico, would allow scientists to use data from multiple undersea cables to both detect and measure earthquake activity, including pinpointing the epicenter and estimating the magnitude. They were able to sense quakes in New Zealand and Japan from a land-based fiber-optic cable in England, and measure an earthquake in the Malta Sea from an undersea cable running between Malta and Sicily that was located more than 50 miles away from the epicenter.

A map of the world's undersea cable connections with a diagram of how lasers can measure their movement
Marra et al., Science (2018)

Seismic sensors installed on the sea floor are expensive, but they can save lives: During the deadly Japanese earthquake in 2011, the country's extensive early-warning system, including underwater sensors, was able to alert people in Tokyo of the quake 90 seconds before the shaking started.

Using existing cable links that run across the ocean floor would allow scientists to collect data on earthquakes that start in the middle of the ocean that are too weak to register on land-based seismic sensors. The fact that hundreds of thousands of miles of these cables already crisscross the globe makes this method far, far cheaper to implement than installing brand-new seismic sensors at the bottom of the ocean, giving scientists potential access to data on earthquake activity throughout the world, rather than only from the select places that already have offshore sensors installed.

The researchers haven't yet studied how the laser method works on the long fiber-optic cables that run between continents, so it's not ready for the big leagues yet. But eventually, it could help bolster tsunami detection, monitor earthquakes in remote areas like the Arctic, and more.

[h/t Science News]

nextArticle.image_alt|e
iStock
AI Remade Old Music Videos, and You'll Never See 'Sabotage' the Same Way Again
iStock
iStock

From rewriting Harry Potter scripts to naming guinea pigs, getting artificial intelligence to do humans' bidding is the latest trend in internet entertainment. Now, we can all enjoy AI remakes of iconic music videos such as "Sabotage" by the Beastie Boys, "Total Eclipse of the Heart" by Bonnie Tyler, and "Take On Me" by A-Ha.

As spotted by Co.Design, these "neural remakes" were uploaded to YouTube by Mario Klingemann, an artist-in-residence at Google Arts. The AI model he created is capable of analyzing a music video and then creating its own version using similar shots lifted from a database of publicly available footage. The results are then uploaded side-by-side with the original video, with no human editing necessary.

"Sabotage," a spoof on '70s-era cop movies, might be the AI's "most effective visual match," at least by Co.Design's estimate. The AI model found accurate matches for vintage cars and foot chases—and even when it wasn't spot on, the dated clips still mesh well with the vintage feel of the original video. Check it out for yourself:

"Total Eclipse of the Heart," a bizarre video to begin with, spawned some interesting parallels when it was fed through the AI model. Jesus makes a few appearances in the AI version, as does a space shuttle launch and what appear to be Spartan warriors.

And finally, 11 years after the original rickroll, there's now a new way to annoy your friends: the AI version of Rick Astley's "Never Gonna Give You Up," featuring John F. Kennedy and Jesus, yet again. This one is presented on its own in full-screen rather than split-screen, but you can rewatch the original video here.

To see more videos like this, check out Klingemann's YouTube channel here.

[h/t Co.Design]

SECTIONS

arrow
LIVE SMARTER
More from mental floss studios