# USB3 flasdrive too slow with Gentoo [Solved]

## apiaio

Hi there.

After plugin the USB3 Kingston key, I can see *Quote:*   

> localhost / # lsusb
> 
> Bus 002 Device 004: ID 1462:8801 Micro Star International 
> 
> Bus 002 Device 003: ID 0c45:6340 Microdia 
> ...

 So I think that everything is OK. But transfer speed  is only cca 400 kB/sec. I have Sabayon installation on the same machine and there is speed cca 60 MB/sec. Probably I have something neglected in kernel configuration, but I do not what.Last edited by apiaio on Fri Feb 07, 2014 8:24 pm; edited 1 time in total

----------

## eccerr0r

Same kernel version on both?  Same mount options (sure you're not mounting sync?)

I have yet to try my usb3 flash drive...

----------

## apiaio

 *Quote:*   

> localhost / # uname -r
> 
> 3.10.25-gentoo
> 
> 

 and *Quote:*   

> linux-3.9.0-sabayon

 mount points:Gentoo *Quote:*   

> /dev/sdd1                /media         vfat   defaults,noauto,sync,group,gid=15,umask=0002 0 0

 Sabayon *Quote:*   

> none                    /proc/bus/usb   usbfs   devgid=85,devmode=0666  0 0
> 
> 

 Even if Sabayon is Gentoo based binary system there is many differences in config files and Sabayon's mount point doesn't work in Gentoo for me.

----------

## Anon-E-moose

I've plugged in usb3 hard disks and a sandisk usb3 flash drive and had no problems with speed not being usb3, ie greater than usb2

Edit to add:

 *Quote:*   

> /dev/sdd1                /media         vfat   defaults,noauto,sync,group,gid=15,umask=0002 0 0

 

From the man page for mount:

sync   All  I/O  to the filesystem should be done synchronously. In case of media with limited number of write cycles (e.g. some flash drives) "sync" may cause life-cycle shortening.

From me: Sync should make writes much slower.

----------

## apiaio

 *eccerr0r wrote:*   

> Same kernel version on both?  Same mount options (sure you're not mounting sync?)
> 
> I have yet to try my usb3 flash drive...

 Now I noticed sync mount option - that was the problem.

Thanks

----------

## Anon-E-moose

What I do is when writing to a flash drive, is do the writes, then do a sync when done with all writes,

then do a proper eject so that the data stay consistent.

----------

## eccerr0r

yep takes some discipline not to randomly yank the USB drives.  It's best to shut off auto sync, manually sync and unmount before you disconnect.  Overall it might be a bit more hassle but your data and disk will appreciate it.

I forget but there was a mount option to only sync if there's no write activity for a short period...  This way it minimizes risk of accidentally yanking the drive before unmounting.

Can't remember what it is though...

----------

## apiaio

Could anyone of you explain why and how to do a sync after the writes?

----------

## Anon-E-moose

type in "sync" it will sync all mounted filesystems/drives 

I use a script called suspend-usb-device that I ran across on the net, that acts like the MS windows hardware eject option.

Just to make sure on my usb3 drives, it will even work on flash drives, though the sdparm commands are useless for it.

 *Quote:*   

> suspend-usb-device  Copyright (C) 2009  Yan Li <elliot.li.tech@gmail.com>
> 
> This script is designed to properly put an USB device into suspend
> 
> mode that can then be unplugged safely. It sends a SYNCHRONIZE CACHE
> ...

 

I modified it for my purposes, it works well enough. 

I've not had any data corruption since doing sync and then the eject.

----------

## gotyaoi

There's also the 'flush' mount option as opposed to 'sync' or 'async'. It's a bit of a compromise between the buffer nothing of 'sync' and the hold on to buffers as long as possible of 'async'. You might try it and see if it works for you.

----------

## Anon-E-moose

 *gotyaoi wrote:*   

> There's also the 'flush' mount option as opposed to 'sync' or 'async'. It's a bit of a compromise between the buffer nothing of 'sync' and the hold on to buffers as long as possible of 'async'. You might try it and see if it works for you.

 

It would not help his problem with buffers flushing, it would just change when it was done, earlier vs later.

 *Quote:*   

>  flush  If set, the filesystem will try to flush to disk more early than normal.  Not set by default.

 

In his case turning off sync will give him decent speed.

With a big enough data transfer the buffers will flush when they get full, regardless of sync (mount) or not.

I like to do a sync after all data is sent to a disk, but it's really unnecessary as an umount will sync all data to the filesystem before unmounting.

But that's only to the filesystem, it doesn't cause the disk to flush it's own buffers, which is why I use the eject script.

One could always just run the sdparm command to flush the disk also. I just find a single script easier to run than remembering 

what to tell sdparm.

----------

