dd reports in bytes, not megabytes

Hi,

When I use dd to check the read/write performance of my drives I only get the results in bytes and I really prefer it to report in mega/gigabyte.

On my Linux boxes this is standard, it reports like this for example:
[cmd=]dd if=/dev/zero of=foo3 bs=1M count=1000[/cmd]
Code:
Output: 1048576000 byte (1,0 GB) copied, 26,0484 s, 40,3 MB/s

And on my FreeBSD box it reports like this:

Code:
Output: 1048576000 bytes transferred in 0.300587 secs (3488425586 bytes/sec)

Which is a little harder to read. I couldn't find any options that makes the output in human readable format.
How do I fix this?

Thanks,
-Patric
 
SirDice said:
There isn't one.

There's nothing to fix if it's not there.

Thanks for the quick reply. However is there another option to go with for people that are as lazy as me that don't want to do the math between byte and megabytes?
 
Throw it to bc(1) to do the math for you:

Code:
#!/bin/sh

PATH=/bin:/usr/bin

# mb-maker.sh: feed me an argument to convert from bytes to MB

[ -z "${1}" ] && exit 1

echo "scale = 2 ; ${1} / 1024 / 1024" | bc

exit 0

Pretty crude, but you get the idea.
 
k1piee said:
Thanks for the quick reply. However is there another option to go with for people that are as lazy as me that don't want to do the math between byte and megabytes?

You'd have to be really lazy not to divide number by 1,000,000 and get Megabytes.
 
Megabytes are 1024^2, but that's beside the point. Quick, how many megabytes is 18291042814 bytes? Sometimes, it would be handy to have dd use units other than bytes.
 
wblock said:
Megabytes are 1024^2, but that's beside the point. Quick, how many megabytes is 18291042814 bytes? Sometimes, it would be handy to have dd use units other than bytes.

Megabytes are power of 2, or base 10, depending on context.
So if I ever saw 18291042814 I would very quickly deduce that I'm looking at ballpark of 18.3 GB/s (awesome). If I had to know exactly how much it is down to a byte, there's a calculator!
 
wblock said:
Megabytes are 1024^2, but that's beside the point. Quick, how many megabytes is 18291042814 bytes? Sometimes, it would be handy to have dd use units other than bytes.

While it would be great to have a -h option for dd to humanise the output into B/s, KB/s, MB/s, GB/s, etc as needed, it's really not hard to convert 18291042814 bps into MBps (or GBps).

Just count the number of digits from the right. Every group of 3 is a new unit (B, KB, MB, GB, etc). Thus 18.3 GBps. Basic unit conversion math.

Sure, it's off a bit due to "base 2" and "base 10" muckedy-muck. But it's close enough.
 
Back
Top