You are not logged in.

#1 2012-06-25 14:31:18

seniorsassycat
Member
Registered: 2011-08-27
Posts: 76

When is it safe to unplug a mounted usb drive?

I'm making a headless media player that I want to automatically play music off of any usb stick or hard drive plugged into it. Because it doesnt have a monitor users wont be able to unmount the drive. If the drive is mounted read only is there any possibility of corrupting the data?

Offline

#2 2012-06-25 14:48:35

Cyrusm
Member
From: Bozeman, MT
Registered: 2007-11-15
Posts: 1,053

Re: When is it safe to unplug a mounted usb drive?

Quick answer: on Linux and Mac you should always safely unmount external storage, this is due to data being cached on the external drive during the file transfer. On windows this is not a big deal, as cacheing is not enabled by default.

Honestly, I don't really think you will have too much of an issue, as always ymmv. I may be mistaken, but if I understand correctly mounting a drive with the "sync" option disables this cacheing, might be worth researching furthur.  hopefully all of this helps a little bit.


Hofstadter's Law:
           It always takes longer than you expect, even when you take into account Hofstadter's Law.

Offline

#3 2012-06-25 15:14:42

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: When is it safe to unplug a mounted usb drive?

I would think it would be safe if mounted ro.  Drive caching is for write, not read AFAIK.

But you should go the extra mile: have music files copied to ramdisk if space is available, then unmount the device automatically.  Preempt the reset button to properly unmount any device.  Better yet, if the mobo has any serial ports, they could be used to great effect...


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2012-06-25 15:54:32

seniorsassycat
Member
Registered: 2011-08-27
Posts: 76

Re: When is it safe to unplug a mounted usb drive?

alphaniner wrote:

I would think it would be safe if mounted ro.  Drive caching is for write, not read AFAIK.

But you should go the extra mile: have music files copied to ramdisk if space is available, then unmount the device automatically.  Preempt the reset button to properly unmount any device.  Better yet, if the mobo has any serial ports, they could be used to great effect...

Only 126 mb of ram, so that's a no :-), right now I'm using an old pentium 3 dell but I'll use a raspberry pi once I get my hands on one. What were you thinking of for the serial, an unmount drives button? Can you point me the right way for serial port programming?

Offline

#5 2012-06-25 16:39:08

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: When is it safe to unplug a mounted usb drive?

seniorsassycat wrote:

What were you thinking of for the serial, an unmount drives button? Can you point me the right way for serial port programming?

I can't offer any directions, I just know it can be done.  I've seen 'appliances' based on linux and x86 h/w with a simple switch connected to the serial header.  Pressing the switch causes the IPs of all NICs to return to default, presumably by running a a script or some such.  So an unmount drives button should be pretty simple.  I think something even more complex (like an actual control panel) would be possible too.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#6 2012-06-25 16:52:54

bart_b
Member
Registered: 2012-06-16
Posts: 20

Re: When is it safe to unplug a mounted usb drive?

Technically in terms of read-only you can unplug an USB drive.
Only during a write-cylce eg. the moment when a memory cell is flashed to hold and store the data and you unplug the device a single or a few cells can be damaged in rare occasions. It's more likely you only create a bunch of crc errors and data corruption.

Offline

#7 2012-06-25 17:26:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: When is it safe to unplug a mounted usb drive?

This is a hackish, but probably easy way to get a control interface: get an old keyboard, set up the system to run a script that catches key presses, and make one key unmount drives.

The advantage of an old keyboard: you can tear it apart, and make it into your own interface while hijacking the normal keyboard handling.

Perhaps a 10-key usb keypad would be even better for simplicity's sake.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB