jueves, 1 de septiembre de 2011

Velocidad en discos USB en linux

De: http://www.linux-usb.org/FAQ.html#i5

A:For USB Mass Storage devices (that is, devices which use the usb-storage driver) max_sectors controls the maximum amount of data that will be transferred to or from the device in a single command. As the name implies this transfer length is measured in sectors, where a sector is 512 bytes (that's a logical sector size, not necessarily the same as the size of a physical sector on the device). Thus for example, max_sectors = 240 means that a single command will not transfer more than 120 KB of data.

Linux 2.6 gives you the ability to see and to change the max_sectors value for each USB storage device, independently. Assuming you have a sysfs filesystem mounted on /sys and assuming /dev/sdb is a USB drive, you can see the max_sectors value for /dev/sdb simply by running:

cat /sys/block/sdb/device/max_sectors
and you can set max_sectors to 64 by running (as root):

echo 64 >/sys/block/sdb/device/max_sectors
Values should be positive multiples of 8 (16 on the Alpha and other 64-bit platforms). There is no upper limit, but you probably shouldn't make max_sectors much bigger than 2048 (corresponding to 1 MB, which is quite a lot).

In general, increasing max_sectors will improve throughput since it means that larger amounts of data can be transferred in a single command with no need for being split up among multiple commands. Of course this is subject to diminishing returns when max_sectors is very big. More importantly, it's true only up to a point. Many devices have limits on the amount of data they can transfer, and if you try to exceed that limit you will most likely crash the device.