Linux – Test USB 3.0 Device Speed

bashddlinuxUbuntuusb-3

I've looked up the hdparm command, but all examples are for testing disks. Not sure if it can be used to test external usb devices (specifically a usb flash stick).

I'm using this code right now:

dd if=/dev/zero of=/media/storage/speed_test.txt bs=100K count=1k
sudo /sbin/sysctl -w vm.drop_caches=3
dd if=$/media/storage/speed_test.txt of=/dev/null bs=100K count=1k

What are the ranges of read and write speeds I should expect? I got ~900 MB/s for write and ~500 MB/s for read and I think the numbers are too high. Am I not clearing the cache correctly? What other commands I can use to test the speed?


Update:

Thanks to user427539’s answer and zloster’s comment, I now have a more accurate measurement of speeds. I'm testing with a 16GB USB flash stick and I'm writing and reading 1 GB of data. I got 22 MB/s for writing and 46 MB/s for reading. However, aren't such speeds too slow for a USB3 flash device? Why would the speed be so low?

Best Answer

First that is only 100MB that you are writing. The disk and controller also have a cache that you aren't dropping, so you need a bigger test to make sure those caches aren't corrupting the results.

Bump that up at least 1GB. Maybe by changing to bs=1M. I normally test with 10GB just to be sure.

Then you need to make sure the data actually gets to disk, add "conv=fdatasync" at the end of the first line to do that.

As to normal speeds, USB2 devices / ports normally do between 10 and 20 MB/sec. USB3 devices should be between 50 and 150MB/sec. I'm very happy if I see a new device hit 120MB/sec. That's 7.2GB/min which is really fast.

But be aware a rotating disk reads/writes at the speed the platter spins under the head. Thus it you know the density (bits/inch) you can calculate the data speed:

throughput = radius * 2PI * density * RPM

The density you can't really control, but the RPM you can, the more RPMs the faster the raw speed.

Also, note that the radius of the platter changes based on where the head is. It might be about 1.75 inches on the outer track, but only 0.75 inches on the inner track. That means the drive will really slow down as you move from the outer track to the inner. Virgin drives typically have you writing to the outer track first, so you get much better speed at first. As the drive fills up it gets slower. I routinely see a 50% drop off in performance with a almost full drive.

Related Question