婉兮清扬

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

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
上一篇 下一篇

 
姓名:
评论:

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

日照香炉生紫烟,遥看瀑布挂前川。
飞流直下三千尺,疑是银河落九天。

答案:

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

2020年12月31日
洛杉矶

最新评论


2026-07-23 11:37:04
qyjohn 评论了 《几句翻译》

2026-07-21 20:11:28
wells 评论了 《几句翻译》

2025-11-15 06:29:51
qyjohn 评论了 《青桔》

2025-11-14 01:55:04
wells 评论了 《青桔》

2025-10-24 18:04:06
Ted Wang 评论了 《关于作者(About Me)》

2025-03-27 08:28:09
Max 评论了 《父亲走了》

2025-03-08 04:13:52
W 评论了 《我不想颂扬普京大帝》

2024-07-22 16:02:03
云思 评论了 《无题》

2024-06-27 10:01:54
yiming 评论了 《致访客(Welcome)》

2024-05-06 08:50:06
qyjohn 评论了 《致访客(Welcome)》

2024-05-03 19:49:00
jimmie 评论了 《致访客(Welcome)》

2024-02-19 03:32:57
林小静 评论了 《埋剑渡》

2024-01-05 03:54:28
路过者 评论了 《2023年度盘点》

2024-01-04 10:22:05
qyjohn 评论了 《致访客(Welcome)》

2024-01-04 08:05:13
qyjohn 评论了 《2023年度盘点》