How to determine the size of the base at 1000 or 1024, when we see kb or mb

There are many programs on Linux that display the size of a file, some of them in blocks, and some in bytes. But when it comes to some kind of human-readable form, such as ls -sh, lvs, dd bs = size, and as many as we can decide whether it will be a multiple of 1024 or 1000, when we see kb, KB, mB, MB, K, G, etc. Some distinguish them by capitalization, for example, lvs, some with different characters, such as dd, however there is a general rule for such things, because I can’t find it yet. Thanks.

+4
source share
1 answer

If you look at man units , you will see a description of two types of units. Decimal and binary. Decimal units such as Kilobyte (KB) and Megabyte (MB) are 1000 (10 ^ 3), while binary units such as Kibibyte (KiB) and Mebibyte (MiB) have a multiplicity of 1024 (2 ^ 10).

If the displayed device includes a binary prefix, such as KiB, MiB, GiB, you can be sure that it is 1024. For obscure units, the general rule of the thumb is:

  • Hard drive sizes are advertised in decimal units because manufacturers want to make them larger. Accordingly, the size of files stored on disk and transferred over networks is generally consistent with this.
  • Memory sizes advertised in binary units
  • Everything that is not connected with the data (frequency in kHz, etc.) is always equal to decimal

Ubuntu published a policy in 2010 for its devices, which appears to be fairly consistent across Linux distributions, although it is not guaranteed:

  • Use base-10 for:

    • network bandwidth (e.g. 6 Mbps or 50 kB / s)
    • disk sizes (e.g. 500 GB hard drive or 4.7 GB DVD)
  • Use base-2 for:

    • RAM sizes (e.g. 2 GB RAM)

There are two possibilities for file sizes:

  • Show both base-10 and base-2 (in that order). For example, the Linux kernel: "2930277168 512-byte hardware sectors: (1.50 TB /1.36 TiB)"
  • Show only base-10 or give the user the opportunity to choose between base-10 and base-2 (the default should be base-10).
+2
source

Source: https://habr.com/ru/post/1493564/


All Articles