[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Preventing delayed USB writes



On Tue, May 15, 2007 at 09:01:57PM -0500, Ron Johnson wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 05/15/07 20:37, H.S. wrote:
> > pedxing wrote:
> >> Lenny AMD64.
> >>
> >> When I write to a USB device (stick or mp3 player), I notice that
> >> the writes appear to happen quickly, but actually take a long time to
> >> complete.  I assume there is some form of caching going on.
> >>
> >> To be safe, I issue a sync command from a terminal and wait for it
> >> (up to 15 minutes!) to complete before unmounting the drive.
> >>
> >> Is there any way to prevent the caching from occuring?  I would like
> >> to configure things so that, for instance, when I (ok, actually my
> >> wife) use konqueror to copy songs to my mp3 player, when the copy
> >> dialog says 100%, I can immediately unmount the device without
> >> having to wait for a delayed write.
> > 
> > I am not sure if you realize this, but you cannot do that even in
> > Windows. There you actually have to click on the little USB icon on the
> > system tray and choose to "remove the device safely". This is exactly
> 
> Well, you learn something new every day...
> 
> > what we do in Linux as well, well, at least in Gnome and KDE. In KDE for
> > example, you right click on the USB icon and click on "safely remove".
> > In both cases, it is never a good idea just to yank out the usb device,
> > otherwise is likely you will get corrupted data on your USB device.
> 
> <QUESTION STYLE=RHETORICAL>
> And why, pray tell, can't you just yank out the stick?
> </QUESTION>

The memory chips in a memory stick are special, not the same as RAM
chips.  They don't need continual refresh to keep the data valid, AND
they do write data in relatively large blocks and have a relatively
short service life if blocks are frequently rewritten. Their best life
is had if the OS caches the data in RAM and only writes to the stick
infrequently, like maybe just once at the point where you are about to
dismount it. You should _not_ use ext2/3 on these, unless you figure
out how to disable the constant updating of the last access time on
the fs. But I suppose that in this modern world everything is
disposable, including memory sticks.


-- 
Paul E Condon           
pecondon@mesanetworks.net



Reply to: