I added 500MB vdisk and it's showing 524MB at fdisk -l, Why?

1

I added via vSphere 5.5 a new Hard Disk of 500MB to a virtual machine and the server sees it as 524MB.

Any idea why?

fdisk -l
>Disk /dev/sdg: 524 MB, 524288000 bytes
>64 heads, 32 sectors/track, 500 cylinders
>Units = cylinders of 2048 * 512 = 1048576 bytes
>Sector size (logical/physical): 512 bytes / 512 bytes
>I/O size (minimum/optimal): 512 bytes / 512 bytes
>Disk identifier: 0x00000000
linux
hard-drive
vsphere
asked on Super User Sep 2, 2015 by Bizrt • edited Sep 7, 2015 by Bizrt

1 Answer

5

the Metric prefix Mega- has a couple different implications in different areas of IT, and with Disks it's particularly confusing. Traditionally, Metric Prefixes are powers of 10, but early in IT history, prefixes like kilo, Mega, and Giga were used to present approximated values in powers of 2, when converted to decimal.

Disk manufacturers take the prefix literally and measure a KB as 1000 (10^3) bytes, whereas in actual use, a kilobyte's size must be a power of 2 (since its composed of Bits), and is commonly accepted to be 1024 Bytes (2^10). A MB to Disk Manufacturers is 1000000 Bytes, whereas to everyone else, it is 1048576 (2^20), including your OS, so when you store a 1KB file, it takes 1024 bytes on disk. One exception however, due to its strong link to disks, is fdisk.

In the old days, the numbers were so small that we could ignore the extra 24 bytes on a KB, but as capacities expand, the more Metric Prefixes and Binary Prefixes diverged, and the difference became non-negligible. At the Terabyte scale, we lose close to 70GB in conversion. For this reason, many folks now use Binary prefixes explicitly to avoid confusion. VMWare has chosen to do exactly this.

Kilo => 10^3
Mega => 10^6
Giga => 10^9
Tera => 10^12

Kibi => 2^10 (1,024)
Mebi => 2^20 (1,048,576)
Gibi => 2^30 (1,073,741,824)
Tibi => 2^40 (1,099,511,627,776)

So, in this case, you have VMWare using MiB, and FDisk using MB, so there will be a mismatch in the figures.

From VMWare's perspective, you asked for 500MiB, and it gave it to you, but from Fdisks perspective it is a 524MB volume. The two values are exactly the same however.

So, for a 500MiB volume, the size calculation is:

500 * 1048576B = 524288000B => 500 MiB which equals 524MB

for a 500MB disk however, the calculation would be:

500 * 1000000B = 500000000B => 500MB which equals 476MiB so you would not be able to store 500MB of actual data in it.

answered on Super User Sep 3, 2015 by Frank Thomas • edited Jul 11, 2017 by Frank Thomas

User contributions licensed under CC BY-SA 3.0