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
12-02-2011, 09:54 AM
Timothy Redaelli
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/
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
12-02-2011, 10:03 AM
Nicolas Sebrecht
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
12-02-2011, 10:09 AM
Paul Gideon Dann
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
12-02-2011, 10:09 AM
Timothy Redaelli
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?
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
12-02-2011, 12:44 PM
Paul Gideon Dann
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
12-02-2011, 12:51 PM
Paul Gideon Dann
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
12-02-2011, 12:54 PM
Karol Blazewicz
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