It’s pretty common for me to have to make size conversions between 512 byte blocks and something more readable, such as Megabytes or Gigabytes. I’ve got a simple formula to do the conversion.
How to convert 512k byte blocks to Megabytes or Gigabytes
In simple terms the formula to convert from 512 byte blocks to megabytes is:
Number Of 512 byte blocks/2/1024
and to Gigabytes it is:
Number Of 512 byte blocks/2/1024/1024
The reason that I am making this calculation is because I often work on IBM AIX, the default output of the du command is in 512 byte blocks. I believe this is a POSIX standard. But it is really not easy to read at a glance. Recent versions of AIX have an option on the df command to produce human readable output, but I sometimes work on ancient versions.
So for my own sake as much as anyone else’s I quickly wrote this little converter so that in future I don’t need to refer to the formula above and can just quickly get the result.
Converter for 512k byte blocks
Simply enter the output provided by the df command into the textbox below and the sizes in Megabytes and Gigabytes will be displayed.Number of 512 byte blocks
Hope this helps someone, I know it will help me!
If you want more information on how to do these conversions, there is a really good article on it by Brian Smith on his blog: