# dd reports in bytes, not megabytes



## k1piee (May 11, 2011)

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]

```
Output: 1048576000 byte (1,0 GB) copied, 26,0484 s, 40,3 MB/s
```

And on my FreeBSD box it reports like this:


```
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 (May 11, 2011)

k1piee said:
			
		

> I couldn't find any options that makes the output in human readable format.


There isn't one.


> How do I fix this?


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


----------



## k1piee (May 11, 2011)

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?


----------



## anomie (May 13, 2011)

Throw it to bc(1) to do the math for you: 


```
#!/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.


----------



## bbzz (May 13, 2011)

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.


----------



## wblock@ (May 13, 2011)

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.


----------



## fwaggle (May 13, 2011)

Install sysutils/coreutils, then alias gdd to dd?


----------



## bbzz (May 13, 2011)

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!


----------



## k1piee (May 13, 2011)

fwaggle said:
			
		

> Install sysutils/coreutils, then alias gdd to dd?



oh I had no idea that there was a GNU port to FreeBSD, that actually worked like a charm! Thanks for the tip 
And thank everyone else for the comments.


----------



## phoenix (May 13, 2011)

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.


----------

