How do I test a USB drive using `dd`?

0

I've bought a 32GB USB stick, but I have doubts if it's not faulty... formatted as NTFS, writing speed easily falls to ~40 kbps, which means copying even relatively small (a few hundred MB) data can take ages. Persists on two independent Linux Mint laptops.

I'm thinking about returning it to shop, so I thought I'd need some kind of a proof of the drive's faultiness. I thought I'd try to dd random data into the drive, measure time taken, and then compare the correctness of the data. However, I don't know much about such testing though, and I can't be sure if what I was thinking to do would be reliable in any way...

inxi reports the drive to have 31.1 GB, and manufacturer says its read speed should be around 110 MBps. So..

dd if=/dev/urandom of=~/in.iso bs=4M count=7775
openssl dgst -md5 ~/in.iso
time dd if=~/in.iso of=/dev/sdb bs=4M count=7775
time dd if=/dev/sdb of=~/out.iso bs=4M count=7775
openssl dgst -md5 ~/out.iso

A little explanation here: I'm assuming this 31.1 GB reported by inxi means 31.1 gigabytes, not gibibytes, right? Similarly, I hope giving dd bs of 4M means four megabytes, not mebibytes, so 4M*7775 will equal 31100 MB = 31.1 GB. Am I right?

Also: I believe wrong values of bs can impact performance severely, and I'm trying to find a proof of extremely poor performance, so it's important to set those values right... Will 4M do?

Are there any other issues with my idea of testing a drive?

gaazkam

Posted 2016-12-08T03:03:09.103

Reputation: 583

Fun... If formatted under ext4, writing regular files has much more acceptable speed, around 5 MBps... Has frequent hiccups though. – gaazkam – 2016-12-08T03:06:01.933

If the drive is working .. that is, you can read and write to it and it's reporting the appropriate amount of space, then I'd wager that it's in fact not faulty. Slow write speeds are not uncommon with USB drives of all sizes .. To that though, what allocation size are you using when you format in NTFS? If it's the default then chances are it's 4k .. try upping to 32k or 64k when you format it and see if that doesn't improve your write speeds ... – txtechhelp – 2016-12-08T04:29:51.770

No answers