Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

can you measure the transfer speeds of usb memory devices?

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
hthi
Posts: 213
Joined: 2015-05-09 15:43
Has thanked: 1 time

can you measure the transfer speeds of usb memory devices?

#1 Post by hthi »

debian 8 64bit mate main
usb memory sticks
usb hdds

Is there a program that can measure the write and read speeds of usb storage devices?
Thanks.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: can you measure the transfer speeds of usb memory device

#2 Post by GarryRicketson »

Is there a program that can measure the write and read speeds of usb storage devices?

Yes there is, Actually there are many.
There are also some simple commands for that, no need for any "programs".

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: can you measure the transfer speeds of usb memory device

#3 Post by debiman »

here's a script that just uses dd.
it is non-destructive, but requires root privileges for some actions.
also note the link at the bottom.

Code: Select all

#!/bin/bash

me="$(basename "$0")"
search_usb="/run/media/$USER"
bs="1M"
count="256"
statfile="/tmp/$me.stats"
sep="========================================================================="

function usage {
echo "Usage:
	$me [device or path]

Test a mounted storage device's read/write speed and output results.
	Prerequisites:
		- the device is mounted and
		- there is at least $count x $bs free space on it.

You can provide the full path to the device's mountpoint, or the label it
shows up under $search_usb.
If you provide neither, the current path is assumed to be on the drive to be
tested.

The script will require sudo authentication to clear the buffer-cache to
accurately measure _read_ speeds directly from the device.
"
exit 1
}
function cleanup {
	rm
}

[ "$@" = "-h" ] || [ "$@" = "--help" ] && usage

if [ "$#" -gt 0 ]
then
	if /usr/bin/ls -1 "$search_usb" | /usr/bin/grep -Fxq "$@"
	then
		mountpoint="$search_usb/$1"
	else
		if [ -d "$@" ]
		then
			mountpoint="$@"
		else
			echo "ERROR: \"$@\" is not a directory.
	"
			usage
		fi
	fi
else
	mountpoint=.
fi

trap "rm \"$mountpoint/$me.tempfile\"" EXIT

#~ dev="$(/usr/bin/mount | /usr/bin/grep -F "$mountpoint")"
#~ dev="${dev%% *}"

#~ echo "$dev"

echo "$sep"

df -h "$mountpoint"
echo "
===== Writing ====="
dd if=/dev/zero of="$mountpoint/$me.tempfile" bs="$bs" count="$count" conv=fdatasync,notrunc status=progress 2>&1 | tail -1

echo "
===== Reading ====="
sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"
dd if="$mountpoint/$me.tempfile" of=/dev/null bs="$bs" count="$count" conv=fdatasync,notrunc status=progress 2>&1 | tail -1

echo "$sep"

exit 0

# See: wiki.archlinux.org/index.php/Benchmarking/Data_storage_devices#Using_dd
written for archlinux, you might need to adjust some stuff.

Post Reply