fdisk and lsblk report different disk size

By , 2015年2月5日 7:00 上午

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

Leave a Reply

Panorama Theme by Themocracy