0

I have a USB hard drive of 32 GB, I want to know the time it takes to copy 1 GB of data from the USB drive. I tried using dd if=/dev/sdb1 of=/dev/null

The output is this

dd if=/dev/sdb1 of=/dev/null bs=1G
 28+1 records in
 28+1 records out
 30751983616 bytes (31 GB) copied, 331.297 s, 92.8 MB/s

is the approach used by me is correct or am I doing it wrong. I cannot use other tool, I have to use dd command only.

4

Your command is incorrect, you tell dd to read by 1 GB chunks, but an unlimited number of times. To only measure the time spent to read 1 GB, you need to tell dd to read only one block:

dd if=/dev/sdb1 of=/dev/null bs=1G count=1

Note that buffering will make that command run faster if the device has previously be read.

  • Can we make block size upto 1TB? – Bidyut Nov 18 '16 at 7:19
  • 1
    @Bidyut That depends on your dd implementation, GNU dd accepts even T, P, E, Z, and Y. – jlliagre Nov 18 '16 at 7:23
  • @Bidyut but a portable script should only use the k suffix as this is the only one supported by POSIX. – jlliagre Nov 18 '16 at 7:30
  • @jilliagre I need to do it for 3 TB file system too, and I need to find the amount of time it takes to copy 1 TB of file. – Bidyut Nov 18 '16 at 7:43
  • Your partition size is 30 GB, it cannot hold a 1 TB file system. – jlliagre Nov 18 '16 at 7:46
2

First, as @jiliagre said, you're measuring the transfer time of the whole partition (31 Gb), not 1 Gb. This is shown by the last line of your output:

30751983616 bytes (31 GB) copied, 331.297 s, 92.8 MB/s

Second, since you're writing to /dev/null and hence blackholing the data, it only gives you the read times for your USB drive.

The real I/O transfer time will be bound by the write speed capacity of the destination device, and most probably will be slower.

Furthermore, it depends on which data you're copying. 1 Gb of small files is copied slower than a single 1-Gb file, and takes up more space in the device due to the allocation file size.

  • Can we make block size upto 1TB?? – Bidyut Nov 18 '16 at 7:19
  • I hear its best to lower the block size to match the device you are reading from and increase the count number. – jc__ Nov 18 '16 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.