3

I am writing files to a USB 2.0 drive from a RAM disk, that has a 256MB random filled file on it (created from /dev/urandom to stop the file being compressed too much). When I look at the speeds of the file writes which is output from dd, they are averaging around 75MB/s. This is particularly interesting, because the theoretical maximum speed of USB 2.0 is 60MB/s.

The command that I'm running is:

dd if=/var/mnt/temp_data/urandom of=/mnt/usb/$FILE_NAME bs=10M count=1 

Note that I'm running this multiple times, and I fill the drive to 95% full. The reason for the 10MB files is to make sure that the drive is pretty close to 95% full, and I wouldn't get that sort of fill with larger files, as I don't know what size memory stick will be plugged in, and having multiple files is part of the test.

If motives affect write speed, what I'm doing is testing the write speed of the USB ports on a system to see if they conform to USB standards. Hence this being relatively distressing, and the filling from /dev/urandom (indirectly).

So why is this happening and how do I fix it? I'm assuming that the measurements that dd is outputting is inaccurate, otherwise I'll start selling USB driver writers my secrets.

(Apologies if this should be on unix.se, I wasn't sure)

Yann
  • 239

1 Answers1

2

Ok, so following all the comments and our lengthy discussion in chat here is the answer to the question:

When you are testing the write speed on the system, whether it is writing to USB or HDD, writing to FilesSystem or directly to disk in RAW mode, always make sure to write enough data to fill the cache. If not enough data is written, you are measuring the speed of writing to cache (which is in RAM)

OP, has attempted to write 10MB files in a loop executing sync command between write sessions.

What effectively happened, was that dd command that did the writing would write data to cache very quickly. Reported speed was around 75MB/s. After that sync command would take several seconds to execute, but OP did not take this into account.

After changing the test to write larger files, it was revealed that actual write speed is around 2.2MB/s which is well withing USB 2.0 standards

Art Gertner
  • 7,429