# Good alternative to sync mount option for USB sticks?

## schiotz

I like to mount my USB stick with the sync option, with this line in my fstab

```
/dev/sdb1               /mnt/usb        vfat            noauto,user,sync
```

This way my cp command does not terminate before the file is copied, and I am less likely to get a corrupted file system by pulling out the stick too early.  Now I notice that this has the side effect of making write 100 times(!) slower.  Is there an alternative, e.g. where the syncing is only done when the file is closed?

/Jakob

----------

## tobr

 *schiotz wrote:*   

> [snip]
> 
> This way my cp command does not terminate before the file is copied, and I am less likely to get a corrupted file system by pulling out the stick too early.
> 
> [snip]

 

How about unmounting the stick before removing it? The umount command does not terminate before all buffers are written to the stick. Or use the sync command. But you really should unmount the stick before removing it.

----------

## Gusar

With kernel 2.6.19, a new function was introduced for usb sticks - flush. Here's my fstab line:

```
/dev/sdb1       /mnt/sdb1       vfat    user,flush,noauto    0 0
```

But in any case, you really should unmount the stick before unplugging it.Last edited by Gusar on Tue Feb 06, 2007 2:44 pm; edited 1 time in total

----------

## tobr

 *Gusar wrote:*   

> With kernel 2.6.19, a new function was introduced for usb sticks - flush.

 That's interesting, what exactly does it do?

----------

## Gusar

Wow, you're quick  :Smile:  I come back to edit my post and there's already an answer.

It does exactly what you want. Here's where I read about it and have been using it since.  *Quote:*   

> FAT: Add "-o flush" mount option for fat for removable media devices (USB flash-based memory devices, MP3 players). Mounting with -o flush tells FAT to write things to disk as quickly as possible. It is like -o sync, but much faster (and not as safe). Think of it like a fast "async" mount

 

----------

## schiotz

Thanks for all your replies.  I do unmount before pulling it out - except in the rare cases where I forget, and then it looks like the flush option will be the one to minimize the damage. 

Thanks again for all your input.

/Jakob

----------

## Xanadu

(This is an old-ish thread, but I hope someone sees this)

How do I get udev to automatically add the flush (or sync) option when it mounts my flash disk?  I guess I could put in a fstab entry for it, but frankly, that's a bit too much of a "hack" for my tastes.  I'd much rather alter a udev rule to add "flush" or "sync" (the pluses and negatives of either are not in my question since I've already looked all that much up) to the mount options.  

Can someone point me in the right direction for this?

Thanx!

M.

----------

## coolsnowmen

how and why do you use udev to mount things,

I ask because:

the typical use for udev is for automatic creation of device nodes

the typical way to automount usbsticks is through hal at the lowest point...

----------

## Xanadu

 *coolsnowmen wrote:*   

> how and why do you use udev to mount things,
> 
> I ask because:
> 
> the typical use for udev is for automatic creation of device nodes
> ...

 

Well, OK, then 's/udev/HAL/'.  Whichever actually does the mounting isn't terribly important.  How do I alter it's config to add the flush or sync option when it mounts is what I'm asking.

Thanx.

----------

## coolsnowmen

I ask, because the top level of the auto mounting chain can specify whatever it wants.

I use kde, and my usbstick automounts with flush already. (it is kde that is doing the mounting)

```
/dev/sde on /media/disk type vfat (rw,nosuid,nodev,noatime,flush,uid=1000,utf8,shortname=lower)
```

and I havn't done anything special.

a while ago i looked at ivman (when I wasn't using kde) and in that you could look at hald properties and append mount options...

----------

