USB flash drive performing slowly in Linux
Q My USB flash memory has recently become very slow, giving only around 5Kb/s on writes. I run Gentoo Linux and this problem seems to have started since I upgraded to a 2.6.12 kernel.
A This is due to a change in the way the kernel handles the sync option with FAT filesystems. Previous kernels only kept the data in sync and updated the FAT table at the end of the operation. The later revisions update the FAT table each time a block is written. This slows down writing substantially, but far more importantly, it also seriously shortens the life of the drive with so many writes to the same place. I managed to destroy a 1GB memory stick (and three weeks' work) in a few weeks before learning of this. It is normal practice to mount removable devices with the sync option, to reduce the chances of corrupting data by unplugging them without unmounting, but this new kernel 'feature' means you should now mount your device without this option. If you mount manually, this is easy: just change the entry in /etc/fstab to remove the sync option. If you use HAL to mount drives automatically, you can change the default mounting policy from sync to async by saving the following in a file called /etc/hal/fdi/policy/storage-policy.fdi:
<match key="volume.size" compare_ lt="2147483648"> <match key="@block.storage_ device:storage.hotpluggable" bool="true"> <merge key="volume.policy. mount_option.sync" type="bool">false</merge> <merge key="volume. policy.mount_option.noatime" type="bool">true</merge> </match> <match key="@block.storage_ device:storage.removable" bool="true"> <merge key="volume. policy.mount_option.sync" type="bool">false</merge> <merge key="volume. policy.mount_option.noatime" type="bool">true</merge> </match> </match>
If you use Ivman, find the line in /etc/ivman/IvmConfigActions.xml that reads
<ivm:Match name="hal.volume.fstype" value="vfat">
<ivm:Option name="mountoption" value="async" />
immediately after it. You will need to restart HAL/Ivman after making these changes, and don't forget to unmount devices before unplugging them!
- Best Linux distro for a USB flash drive?
- Best Linux distro for a Seagate hard drive?
- Get a Zip Plus drive working in Linux
- LILO boot problems after moving Linux installation to larger hard drive
- Is my USB flash drive destroyed?