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 512 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 512 byte blocks
Enter the number of 512 byte blocks below and the sizes in Megabytes and Gigabytes will be displayed.
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.
This was very helpful, thank you!
Tony Rein says
Just to say thanks — this was very helpful to me while trying to resize some partitions using command-line tools.
It’s not a “Converter for 512k byte blocks” it’s a Converter for 512 byte blocks