• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Tachytelic.net

  • Get in Touch
  • About Me

Convert from 512 byte blocks to Megabytes and Gigabytes

March 26, 2014 by Paulie 3 Comments

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.

Value in Megabytes:
Value in Gigabytes:

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.

Filed Under: Scripts & Utilities, Technical Posts

Reader Interactions

Comments

  1. javier says

    October 19, 2016 at 5:36 pm

    This was very helpful, thank you!

  2. Tony Rein says

    December 2, 2017 at 4:12 pm

    Just to say thanks — this was very helpful to me while trying to resize some partitions using command-line tools.

  3. nobody says

    December 13, 2018 at 5:53 pm

    It’s not a “Converter for 512k byte blocks” it’s a Converter for 512 byte blocks

Leave a Reply Cancel reply

Primary Sidebar

Link to my LinkedIn Profile
Buy me a coffee

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 245 other subscribers.

Go to mobile version