Я добавил 500 МБ vdisk, и он показывает 524 МБ на fdisk -l. Почему?

465
Bizrt lala

Я добавил через vSphere 5.5 новый жесткий диск объемом 500 МБ на виртуальную машину, и сервер видит его как 524 МБ.

Есть идеи почему?

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 
1
потому что VMWare создает диск в мегабайтах, а не в мегабайтах, поскольку ваше хранилище фактически используется с приращением в мегабайтах. `500 * 1048576 = 524288000 => 524 МБ => 500 МБ`. Производители дисков злоупотребляют МБ, чтобы их предложения казались больше, чем они есть на самом деле, поэтому для 1 ТБ хранилища вы получаете только 931 ГБ полезной памяти. В вашем случае, если бы вы на самом деле использовали МБ, у вас было бы `500 * 1000000 = 500 МБ => 476 МБ` фактического полезного хранилища. Frank Thomas 8 лет назад 5
На FrankThomas Это очевидный ответ. Почему бы не опубликовать его как таковой. @OP: Я изменил разметку вашего поста. Отступ с 4 пробелами форматирует вывод. Если вам это не нравится, вы можете вернуть его через [редактировать ссылку] (http://superuser.com/posts/966311/edit). Hennes 8 лет назад 0
@Frank Томас согласился - Фрэнк, ты должен опубликовать это как ответ. Я проголосую за это. Jamie Hanrahan 8 лет назад 0

1 ответ на вопрос

5
Frank Thomas

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.

или как я люблю говорить "Ошибки округления". Это обычно происходит наоборот Journeyman Geek 8 лет назад 0
Для `1000` используйте` kB`, а не `KB` (аналогично SI-килограммам). `2 ^ 20` - это` 1048576`, а не `10048576`. 12431234123412341234123 6 лет назад 0
@ 12431234123412341234123, спасибо. опечатка исправлена. Frank Thomas 6 лет назад 0

Похожие вопросы