FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor


 
 
LinkBack Thread Tools
 
Old 12-02-2011, 09:48 AM
Paul Gideon Dann
 
Default USB Buffering Issue

Hello all,

I've been having some trouble with USB drives in the last few months. When
copying files onto a device, the copy appears to be instantaneous, but is
clearly buffered by the kernel. If I unmount the drive, all appears well, but
then removing the device results in corruption.

In order to work around this, I have to run "sync" before unmounting the
device.

Any ideas what might be causing this, or how to fix it? It would be nice to
get a *real* progress bar when copying large files, instead of a quick flash
followed by a boring minute or more of staring at "sync".

Paul
 
Old 12-02-2011, 09:54 AM
Timothy Redaelli
 
Default USB Buffering Issue

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 12/02/2011 11:48 AM, Paul Gideon Dann wrote:
> Hello all,
>
> I've been having some trouble with USB drives in the last few
> months. When copying files onto a device, the copy appears to be
> instantaneous, but is clearly buffered by the kernel. If I unmount
> the drive, all appears well, but then removing the device results
> in corruption.
>
> In order to work around this, I have to run "sync" before
> unmounting the device.
>
> Any ideas what might be causing this, or how to fix it? It would
> be nice to get a *real* progress bar when copying large files,
> instead of a quick flash followed by a boring minute or more of
> staring at "sync".

Hi,
by default linux mounts the devices with the async option.
You can mount using the sync option, so you are sure that the I/O is
made synchronously.
Just remember: "In case of media with limited number of write cycles
(e.g. some flash drives) "sync" may cause life-cycle shortening."
(from man 8 mount)

My 2 cents

- --
Timothy Redaelli
drizztbsd @ irc.freenode.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBCAAGBQJO2K50AAoJEOcRMG48T4i8vvUIAJw2pkywKb ISjxwZJ6kdePnH
MKIzi8zBW92nzCydL1vNirEtYA6HWMJlj9IfHMheEjAfNzZy3/1FuogbeDirIucr
T3VBLbCi6LPK52Rke5hQJnwCt8E8yJuzvQf+FxRGHBU+kYOF4W bJAqoj7MhllQrN
rEju1wvhdYMEXZ+DUi8EBKY5HneN4Ub2VoLHNDUv47bieXN8Af qck/ykEo2/WdAW
S3HXayUAUz958okdTuvafQtyNAa6jC1o2vjpSC/LSO0ZdqsrMHnf/KkXrKNvgEwh
+OfGydqnFyOlMKTOJErXzAe7UX0ZuJUKZQKZ1LnUYY6r6y1q/g2xEedFkq40W1w=
=QE7j
-----END PGP SIGNATURE-----
 
Old 12-02-2011, 09:58 AM
Paul Gideon Dann
 
Default USB Buffering Issue

On Friday 02 Dec 2011 11:54:45 Timothy Redaelli wrote:
> Hi,
> by default linux mounts the devices with the async option.
> You can mount using the sync option, so you are sure that the I/O is
> made synchronously.
> Just remember: "In case of media with limited number of write cycles
> (e.g. some flash drives) "sync" may cause life-cycle shortening."
> (from man 8 mount)

Yes, that's probably it. I don't see "sync" in the mount options, so I'm
guessing it's being mounted async. Shouldn't udev be taking care of this for
usb drives?

By the way, I'm mounting the drive via udisks (from KDE). So noone else is
seeing this?

Paul
 
Old 12-02-2011, 10:03 AM
Nicolas Sebrecht
 
Default USB Buffering Issue

The 02/12/11, Paul Gideon Dann wrote:
> On Friday 02 Dec 2011 11:54:45 Timothy Redaelli wrote:
> > Hi,
> > by default linux mounts the devices with the async option.
> > You can mount using the sync option, so you are sure that the I/O is
> > made synchronously.
> > Just remember: "In case of media with limited number of write cycles
> > (e.g. some flash drives) "sync" may cause life-cycle shortening."
> > (from man 8 mount)
>
> Yes, that's probably it. I don't see "sync" in the mount options, so I'm
> guessing it's being mounted async. Shouldn't udev be taking care of this for
> usb drives?

No. udev is basically for devices discovery and naming them in /dev.

> By the way, I'm mounting the drive via udisks (from KDE). So noone else is
> seeing this?

Before trying any sync mount option, try to manually sync disks with the
sync command to check if it fixes you issue.

--
Nicolas Sebrecht
 
Old 12-02-2011, 10:09 AM
Paul Gideon Dann
 
Default USB Buffering Issue

On Friday 02 Dec 2011 12:03:52 Nicolas Sebrecht wrote:
> No. udev is basically for devices discovery and naming them in /dev.

Hehe; oh yeah, of course.

> Before trying any sync mount option, try to manually sync disks with the
> sync command to check if it fixes you issue.

Yeah, everything's fine if I use the sync command before unmounting.

Paul
 
Old 12-02-2011, 10:09 AM
Timothy Redaelli
 
Default USB Buffering Issue

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 12/02/2011 11:58 AM, Paul Gideon Dann wrote:
> On Friday 02 Dec 2011 11:54:45 Timothy Redaelli wrote:
>> Hi, by default linux mounts the devices with the async option.
>> You can mount using the sync option, so you are sure that the I/O
>> is made synchronously. Just remember: "In case of media with
>> limited number of write cycles (e.g. some flash drives) "sync"
>> may cause life-cycle shortening." (from man 8 mount)
>
> Yes, that's probably it. I don't see "sync" in the mount options,
> so I'm guessing it's being mounted async. Shouldn't udev be taking
> care of this for usb drives?
>
> By the way, I'm mounting the drive via udisks (from KDE). So noone
> else is seeing this?

You can try to edit the udev mount options:

# echo 'ACTION=="add", ENV{mount_options}="sync"' >
/etc/udev.d/rules.d/99-mount-options.rules

Then you must reload udev rules:

# udevadm control --reload-rules

- --
Timothy Redaelli
drizztbsd @ irc.freenode.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBCAAGBQJO2LIEAAoJEOcRMG48T4i8s/8H/iAWvcTkqfrwaibdcatunT5w
O/eWtnw5cw0xoG9IIu13So+a0EuzvWWly5NcNmd8HVqKlmuHi1gi mTeAuwdmuS46
tqDIcaYHUfw7VobLEPinWgLeA6QVYTiKPpqP6oxdDeydXYs16u b1F5Gk3OAxXDUQ
C3zQpcfFLVb2wSYYwAoo++USWPApVSAtlfW2mt/7Oz3ggJrhgZN9U+dAWRdLFe/b
Kw+nDJCCG3x33nMSLgAfWe4237Bif0Q2OOZfcZ/RFfV7wRiEZ6AtaRknfVvVIBLy
u53BrUqid9u7ZV7CpTvU41ka2py1KeHMBAXkIDvwCzAhgtDnQS i/Tp9gTfURdm4=
=r74L
-----END PGP SIGNATURE-----
 
Old 12-02-2011, 12:37 PM
Nicolas Sebrecht
 
Default USB Buffering Issue

The 02/12/11, Paul Gideon Dann wrote:
> On Friday 02 Dec 2011 12:03:52 Nicolas Sebrecht wrote:

> > Before trying any sync mount option, try to manually sync disks with the
> > sync command to check if it fixes you issue.

Didn't remember you already told it works with sync in your first mail,
sorry.

> Yeah, everything's fine if I use the sync command before unmounting.

How do you umount the USB device?

--
Nicolas Sebrecht
 
Old 12-02-2011, 12:44 PM
Paul Gideon Dann
 
Default USB Buffering Issue

On Friday 02 Dec 2011 14:37:59 Nicolas Sebrecht wrote:
> How do you umount the USB device?

I've done it both from KDE and the command line, but I don't think that really
matters. It's the fact that large files appear to be copied instantly that is
frustrating.

Paul
 
Old 12-02-2011, 12:51 PM
Paul Gideon Dann
 
Default USB Buffering Issue

On Friday 02 Dec 2011 12:09:59 Timothy Redaelli wrote:
> You can try to edit the udev mount options:
>
> # echo 'ACTION=="add", ENV{mount_options}="sync"' >
> /etc/udev.d/rules.d/99-mount-options.rules
>
> Then you must reload udev rules:
>
> # udevadm control --reload-rules

This seems like the right thing to do, but I'd appreciate a little explanation
of the theory behind this fix. I haven't played around much with udev rules so
far. However, this looks like it might mount *all* disks with the sync
option. Could you explain how it's supposed to work?

I would have thought that, as was mentioned earlier, udev wouldn't be
responsible for mount options. Wouldn't that be handled by udisks somehow?

I've tried a "mount -o remount,sync ...", and that fixes the issue, so it's
just a question of figuring out why USB drives aren't getting the sync option
automatically. It used to work OK until about 3/4 months ago. Maybe a new
udev broke this behaviour on my machine?

Paul
 
Old 12-02-2011, 12:54 PM
Karol Blazewicz
 
Default USB Buffering Issue

On Fri, Dec 2, 2011 at 2:44 PM, Paul Gideon Dann <pdgiddie@gmail.com> wrote:
> On Friday 02 Dec 2011 14:37:59 Nicolas Sebrecht wrote:
>> How do you umount the USB device?
>
> I've done it both from KDE and the command line, but I don't think that really
> matters. *It's the fact that large files appear to be copied instantly that is
> frustrating.
>
> Paul

https://wiki.archlinux.org/index.php/USB_Storage_Devices#Mounting_the_USB_stick_as_norm al_user_using_Fstab_with_flush_option
 

Thread Tools




All times are GMT. The time now is 07:31 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org