Making `fdisk -l` display partition sizes by GB/MB

How to make fdisk -l display partition sizes by bytes instead of sectors?

fdisk does not have such options as far as I know.

However, good news is that you can use parted:

# parted -l

It will print partition info like

# parted -l
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/fedora_vm235-swap: 2164MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system     Flags
 1      0.00B  2164MB  2164MB  linux-swap(v1)


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/fedora_vm235-root: 18.8GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system  Flags
 1      0.00B  18.8GB  18.8GB  ext4


Model: Xen Virtual Block Device (xvd)
Disk /dev/xvda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  525MB   524MB   primary  ext4         boot
 2      525MB   21.5GB  20.9GB  primary               lvm


Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdb: 537GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  537GB  537GB  primary  ext4


Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdc: 999GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  537GB  537GB  primary  ext4
 2      537GB   999GB  462GB  primary  ext4


Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdd: 1979GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1979GB  1979GB  primary  ext4
Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *