Are the units in Base 2 (Mib,Gib,Tib) or in Base 10 (MB,GB,TB). They say “MB,GB,TB” but that is commonly misused. mdadm seems to be the only thing that truely has it right.

After analysis LVM shows that its actually showing Base 2 MiB and GiB and TiB

How I figured that out:

First lets see the lvm output that shows the size, then figure out with assumptions which unit is being used. Note: not showing all of the LVM vgdisplay output

# lvm vgdisplay
— Volume group —
PE Size 64.00 MB
Alloc PE / Size 223201/ 13.62 TB
Free PE / Size 160 / 10.00 GB

NOTE: bytes are the universal unit that is equal in base 2 and in base 10. So converting MB to bytes first and then back to the specified unit of TB or GB (TB in the case above – Since I will try and match Alloc PE) will show us the correct size in the unit.

Assumption 1 if it were BASE 10 (TB, GB, MB) fails:
If it were in TB base 10: 64 MB * 223201 would yield a different number then 16.34 TB.
64 * 1000 * 1000 * 223201 / 1000 /1000 /1000 / 1000 =14.284864
Which is nowhere in the ball park of 13.62TB

Assumption 2 if it were BASE 10 (TB, GB, MB) successful:
However in Base2 (TiB, MiB, Gib) we get the right numbers:
First convert 64 MB to bytes (*1024*1024), then multiply by how many extents we have which is 223201, then divide to get TB (/1024/1024/1024) and we get 13.6231 which is exactly as it appears in vgdisplay (and also in the /etc/lvm/backup/lvname backup file)
64 *1024*1024 * 223201 / 1024 /1024/ 1024/1024 = 13.6231079102

Example of good output from mdadm showing how the size is clear

I just show you the lines that matter, not all of the mdadm output:

# mdadm -D /dev/md2
Raid Level : raid5
Array Size : 14627723520 (13950.08 GiB 14978.79 GB)
Used Dev Size : 2925544704 (2790.02 GiB 2995.76 GB)

Notice how we get output in 3 different formats, Bytes (the universal equator of volume sizes), in base 2 (GiB), and in base10 (GB)


Leave a Reply

Your email address will not be published. Required fields are marked *