How to test the speed of an external storage device

Recently, I wanted to test all of my external USB drives, USB sticks, and various other external storage devices to establish which devices were the best performers. I have a USB 2 port on the right hand side of my laptop, and a USB 3 port on the left hand side, and I wanted to test the speed difference between those ports.

Using Linux, this is quite easy to do, without having to install any 3rd party software.

Essentially, we use the Linux tool dd to write a file to the device, read it back, and the output of dd gives us the performance (MB/s or GB/s) of the devices.

echo "Writing..."
dd if=/dev/zero of=tempfile bs=1M count=1024 conv=fdatasync,notrunc

echo "Clearing caches..."
sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"

echo "Reading..."
dd if=tempfile of=/dev/null bs=1M count=1024

echo "Reading from buffer..."
dd if=tempfile of=/dev/null bs=1M count=1024

echo "Cleaning up..."
rm tempfile

echo "Done"

I will follow up this post with a table showing the per device performance that was measured across the USB 2 and 3 ports.

Note that this script won’t run on OSX. You need to remove the fdatasync option, and change 1M to 1m. Once you do that though, the OSX version of dd will run the script, but won’t give you the nice MB/sec reading that Linux will give you. You will have to do some manual calculations to determine the read and write rates.


Posted on Jan 8, 2016 in Articles & How To | Tags: TechnologyLinuxBashUSBBenchmark