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

Re: Preventing delayed USB writes



On May 17, 11:00 pm, Douglas Allan Tutty <dtu...@porchlight.ca> wrote:
> On Tue, May 15, 2007 at 10:55:18PM -0600, Paul E Condon wrote:
> > On Tue, May 15, 2007 at 09:01:57PM -0500, Ron Johnson wrote:
> > > 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.
>
> fstab, noatime

I am going to give sync,noatime in fstab a try, using a scratch stick.

It definitely makes KDE behave correctly: it gives you a more accurate
transfer rate (true 1MB/sec vs. the untrue 6-7MB/sec), when it says
finished copying, it is finished copying and the safely remove works
every time.

I kind of doubt that there will be problems, no one seems to have
issued any dire warnings in the last two years, and the warnings I
have read talk about -possible- problems, I don't see much about
actual documented problems.  If someone reading this definitely knows
that this would be a problem, pls let me know!

I guess I'll throw a script at it and see what happens...

-Ped



Reply to: