Thursday, August 7, 2008

Faster USB Transfers

Problem: Transferring files to my usb harddrive was taking a very long time.
Solutions: Multi-step. Explained below.

Links:
http://www.linuxjournal.com/article/8093
http://www.linuxquestions.org/questions/linux-general-1/slow-pendrive-usb-2.0-uploads-259591/

After reading at the above links, I discovered a few things were causing my problem. First, in /etc/fstab I was mounting my usb drive with the sync option. Change that to async (I think it's the default). Second, the cheap usb hub I bought at a local retailer for ~$10 is not a high speed usb hub. I need to buy a better one.

Third, I think the interface that was in control of the USB controller was not the highest speed module. Evidently there are several interfaces that can be used. On my Debian Etch, ehci and uhci were appearring as loaded modules in the lsmod print out. The uhci_hcd module was grabbing the usb devices according to dmesg. So I used modprobe -r to remove both the ehci_hcd and uhci_hcd modules. Then I used modprobe to install the ehci_hcd. Next I plugged in and mounted my usb harddrive. When transferring files to the usb harddrive I noticed a dramatic increase in transfer speed.

In limited testing (copying one large file with each module loaded), here are some results. With uhci_hcd loaded, I transferred a single 6.1 GB file in 97 minutes 0.033 seconds, for 1.056 MB per second transfer speed. With ehci_hcd loaded, I transferred a single 5.1 GB file in 4 minutes 35.544 seconds, for 21.333 MB per second transfer speed.

So now the question is, how do I guarantee that the ehci_hcd module is loaded instead of the uhci_hcd module? Upon further investigation and testing I've discovered that, I guess it's udev, is smart enough to load the ehci_hcd module when a "high speed" device, like my usb hard drive, is plugged into the usb port. The uhci_hcd module is loaded when a "full speed" device, like my cheap usb hub, is plugged into the usb port.