5

I always thought that when doing:

dd if=/dev/sdx of=/dev/sdy

the report which is displayed once the command finishes, such as:

79304319+0 records in
79304319+0 records out
40603811328 bytes (41 GB) copied, 459.645 s, 88.3 MB/s

contains the speed which corresponds to the slowest one between:

  • The read speed from the input,
  • The write speed to the output,
  • What happens between the read and the write,

that is if I'm copying data from an USB drive which have a read speed of 5 MB/s to an SSD, dd will actually report 5 MB/s, independently of the speed of the SSD.

In practice, I was copying a disk connected to USB 2 (checked it twice, the manual says it's USB 2.0 and even precises the connection speed of 480 Mbps), and noticed that dd reports the speed which varies from 65 to 88 MB/s, that is higher than the maximum speed of 60 MB/s for USB 2.0.

What is happening there?

Is the speed shown by dd the addition of the read speed and write speed (which would mean that the actual speed is approximately 40 MB/s, which makes more sense)?


Additional information: I was doing a copy of a hard disk which presents an increasing number of bad sectors in order to have a clone I can experiment with. After copying the whole disk, the reported speed is indeed higher than expected:

3902854784+0 records in
3902854784+0 records out
1998261649408 bytes (2.0 TB) copied, 26040.5 s, 76.7 MB/s

given that the command was repeated for the first few (2 to 3) gigabytes only. I checked and rechecked, the copied disk is the correct one and the motherboard has no support for USB 3 (and there are no additional PCI-e cards for USB 3).

hdparm's results are even stranger:

$ hdparm -tT /dev/md0

/dev/md0:
 Timing cached reads:   13498 MB in  2.00 seconds = 6755.77 MB/sec
 Timing buffered disk reads: 486 MB in  3.00 seconds = 161.77 MB/sec

$ hdparm -tT /dev/md0

/dev/md0:
 Timing cached reads:   15058 MB in  2.00 seconds = 7536.75 MB/sec
 Timing buffered disk reads: 418 MB in  3.01 seconds = 138.91 MB/sec

$ hdparm -tT /dev/md0

/dev/md0:
 Timing cached reads:   15038 MB in  2.00 seconds = 7527.54 MB/sec
 Timing buffered disk reads: 386 MB in  3.01 seconds = 128.38 MB/sec
3
  • 2
    Although I don't know the reason for your results, dd's reporting how many bytes per second it can transfer from point A to point B. Adding read/write speeds would be incredibly counter-intuitive. I know of no utility which does that. Commented Jun 7, 2015 at 3:09
  • /dev/md0 is a raid array, not your usb drive. Commented Jun 7, 2015 at 23:21
  • Can you run iostat 5 (iostat is part of the sysstat package if you don't have it installed yet) during a disk copy and see whether the read and write numbers for those two disks are close to what dd is reporting? Commented Jun 8, 2015 at 1:30

2 Answers 2

3

Unless you specify oflag=direct or conv=fsync, then the kernel buffers the data and so dd thinks it is done as soon as the kernel has accepted the last of the data, which may be a few seconds before it makes it to the drive. For small amounts of data, that can introduce significant error to the throughput estimate.

1
  • Thank you for your answer. It appears that the speed is still strange when copying the whole disk (2 TB), not just for small amounts of data. Commented Jun 7, 2015 at 21:18
2

In general dd displays the time it took for the entire transfer and the speed is "amount of data divided by time it took". Basically it's the same you should get with time dd ..., no magic there.

40603811328 bytes (41 GB) copied, 459.645 s, 88.3 MB/s
40603811328 / 459.645 / 1000 / 1000 = 88.3373

Maybe you cancelled the dd at some point and restarted it, whereupon a substantial portion of the data was already cached and thus the cache is messing with your statistics? You can try hdparm -tT /dev/disk to get a rough estimate of actual drive speeds.

For USB2 the speed is indeed highly suspect, I hope you did not use the wrong devices by accident.

1
  • Thank you for your answer. Indeed, I cancelled dd and restarted it several times after it copied the first few gigabytes, but the speed is still the same for the whole disk. I checked once more, the disk is the right one and the motherboard doesn't have USB 3 support. Commented Jun 7, 2015 at 21:20

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.