婉兮清扬

案上诗书杯中酒之快意人生

fdisk and lsblk report different disk size

发表时间:2015-02-05 07:00:24
Create an i2.4xlarge instance, SSH into the instance and run "sudo fdisk -l" and then "lsblk". Compare the outputs:
[ec2-user@ip-172-31-5-22 ~]$ sudo fdisk -l

WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/xvda: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt


# Start End Size Type Name
1 4096 16777182 8G Linux filesyste Linux
128 2048 4095 1M BIOS boot parti BIOS Boot Partition

Disk /dev/xvdb: 800.2 GB, 800165027840 bytes, 1562822320 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/xvdc: 800.2 GB, 800165027840 bytes, 1562822320 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/xvdd: 800.2 GB, 800165027840 bytes, 1562822320 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/xvde: 800.2 GB, 800165027840 bytes, 1562822320 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[ec2-user@ip-172-31-5-22 ~]$ df -m
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/xvda1 7934 1062 6774 14% /
devtmpfs 61475 1 61475 1% /dev
tmpfs 61483 0 61483 0% /dev/shm

As we can see, the size reported by fdisk is calculated using the following equation:

size = sectors x bytes per sector

1562822320 sectors x 512 bytes per sector = 800,165,027,840 bytes = 800.2 GB
[ec2-user@ip-172-31-5-22 ~]$ lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 8G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdb 202:16 0 745.2G 0 disk
xvdc 202:32 0 745.2G 0 disk
xvdd 202:48 0 745.2G 0 disk
xvde 202:64 0 745.2G 0 disk

With lsblk, the equation is:

size = bytes / 1024 / 1024 / 1024

800,165,027,840 bytes / 1024 / 1024 / 1024 = 745.2 GB
上一篇 下一篇

 
姓名:
评论:

请输入下面这首诗词的作者姓名。

爆竹声中一岁除,春风送暖入屠苏。
千门万户曈曈日,总把新桃换旧符。

答案:

云与清风常拥有,
冰雪知音世难求。
击节纵歌相对笑,
案上诗书杯中酒。

蒋清野
2000.12.31 于 洛杉矶