2

In many file system related man page, the units are represented by single letters [bBsSkKmMgGtTpPeE]. What do the upper case and lower case mean? I.e. megabyte, megabit, mebiyte, mebibit, which one is which?

jackluo923
  • 21
  • 1
  • 2

4 Answers4

5

Unix tools are not consistent, you need to check the man page of each one.

LVM utilities are consistent, and some (but not all) of the man pages have the details. For example, from lvs(8):

All sizes are output in these units: (h)uman-readable, (b)ytes, (s)ectors, (k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (p)etabytes, (e)xabytes. Capitalise to use multiples of 1000 (S.I.) instead of 1024.

I.e. b or B is bytes, s or S is sectors (of 512 bytes), K is 1000 bytes (SI kilobyte), k is 1024 bytes (kibibyte), M is 1000000 bytes (SI megabyte), M is 1048576 bytes (mebibyte), etc.

More generally, b is never bits in the context of file or disk sizes; it's usually bytes but might occasionally be blocks (and the size of blocks depends on the tool as well). The prefixes k/m/g/t/p/e can mean powers of 1000 or powers of 1024 depending on the tool and sometimes on capitalization. S for sectors as in LVM is unusual. Another common unit (not used by LVM) is c for bytes; this comes from character, from back in the days before multibyte characters were common.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
1

Some LVM commands, such as lvcreate, make no difference between units given as lower-case letters and units given as upper-case letters. b or B means bytes, s or S means sectors of 512 bytes, k or K means binary kilobytes (2^10 = 1024 bytes), m or M means binary megabytes (2^20 = 1 048 576 bytes), g or G means binary gigabytes (2^30 = 1 073 741 824 bytes), t or T means binary terabytes (2^40 = 1 099 511 627 776 bytes), p or P means binary petabytes and e or E means binary exabytes. Documented in man lvcreate under the option -L. Other LVM commands, such as lvs, take lower-case units to mean powers of 2 and upper-case units to mean powers of 10.

Other commands have different conventions. For example dd wants K, M, G for binary units and kB (not KB), MB, GB for decimal units; du and df use K, M, G for binary units and KB (not kB), MB, GB for decimal units; read the manual pages for the commands that you want to use.

No filesystem-related command uses sizes in bits. They are always in bytes.

AlexP
  • 10,217
  • 32
  • 41
-1

Small b letter signifies bit, capital letter B signifies byte

MB/mB = megabyte 
Mb/mb = megabit 

The mathematical explanation is simple:

MiB = Mebibyte = 1024 KiB
KiB = Kibibyte = 1024 Bytes
MB = Megabyte = 1,000 KB
KB = Kilobyte = 1,000 Bytes
Rakib
  • 2,347
  • 1
  • 17
  • 20
  • Only capital letter M should be used for mega, a small letter m means milli, i.e. one thousandth. Kilo should be abbreviated k, not K. K is used for Kelvin, which is a unit for temperature. Often you see K for 1024 and k for 1000, but kiB is a better abbreviation for 2 to the power of 10 bytes. – Johan Myréen Dec 06 '16 at 07:44
  • This is not true in the context of disk or file sizes: they are never expressed in bits, `b` could mean bytes or blocks (bytes in the case of LVM) but not bits. – Gilles 'SO- stop being evil' Dec 06 '16 at 22:35
-2

As mentioned in the man page of lvcreate

-L|--size LogicalVolumeSize[b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E]
Gives the size to allocate for the new logical volume. A size suffix of 
b or B for bytes,
s or S for sectors  as  512  bytes,  
k or K for kilobytes, 
m or M for megabytes, 
g or G for gigabytes, 
t or T for terabytes, 
p or P for petabytes or E for exabytes is optional.
Default unit is megabytes.

Capitalized to used only for present it as multiples of 1000 instead of 1024.
Can also specify custom units e.g. --units 3M

AReddy
  • 3,122
  • 5
  • 35
  • 75