10

doing a fdisk -l is a quite convenient command, but how to make fidsk print the partition size in a unit such as MB or GB?

1
16

You can't. Use something else like parted -l instead.

See man parted for more information.

6
  • thx. So GPT is what Microsoft grants us with by introducing Windows 8? Aug 14 '14 at 18:19
  • 4
    GPT has nothing to do with Microsoft. MBR has just reached its limits and needed a proper replacement able to handle partitions bigger than 2TB and more than 4 primary partitions. By the way, GPT was introduced by Intel. en.wikipedia.org/wiki/GUID_Partition_Table
    – Broco
    Aug 14 '14 at 18:50
  • FWIW fdisk handles GPT fine. See man fdisk :) Nov 19 '15 at 8:46
  • @JeremyDavis: Citing man fdisk (on EL 6,7, Ubuntu 14.04): fdisk does not understand GUID partition tables (GPTs) and it is not designed for large partitions. In these cases, use the more advanced GNU parted(8). This is very clear and also printed if you try to edit a GPT disk with fdisk.
    – Sven
    Nov 19 '15 at 9:17
  • @Sven: not sure what version Ubuntu etc have but Debian Jessie has v2.25.2 and it definitely handles GPT. I used it just the other day to create a new partition on a disk with a GPT! I just posted a copy/paste from one of my machines. Also here is copy of the man that matches my machines: man7.org/linux/man-pages/man8/fdisk.8.html Note the explicit recommendation to use GPT. A quick google shows that support for GPT was added to fdisk in 2012: git.kernel.org/cgit/utils/util-linux/util-linux.git/commit/… Nov 20 '15 at 4:58
4

I'm not sure about other OS; but in Debian Jessie it displays in MB & GB by default.

E.g.:

# fdisk -l /dev/sda

Disk /dev/sda: 1 TiB, 1120239009792 bytes, 2187966816 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
Disklabel type: gpt
Disk identifier: 1D01BF33-C584-4C49-A05F-341CFB8E2D24

Device         Start        End    Sectors   Size Type
/dev/sda1         34       2047       2014  1007K BIOS boot
/dev/sda2       2048     262143     260096   127M EFI System
/dev/sda3     262144  234441614  234179471 111.7G Linux LVM
/dev/sda4  234442752 2187966782 1953524031 931.5G Linux filesystem

Note the 5th column "Size"; K = KiB; M = MiB & G = GiB

4
  • +1, same in 16.04: it displays the size in GB. parted -l is nice though, because start/end are also in human readable units. May 12 '17 at 9:12
  • 2
    MB is not MiB as the original post requested!
    – d hee
    Dec 14 '17 at 2:30
  • 1
    @dhee - Whilst technically you are correct, I would argue that considering that most people (inc Windows, manufacturers of RAM, USB sticks, CD/DVD/BluRay, etc) use KB/MB/GB when they really mean KiB/MiB/GiB, it was a legitimate answer. AFAIK, HDD manufacturers and Apple products are the only ones that use MB/GB/TB when they really mean it. I would further argue that the base 10 units are rarely ever useful on a binary system. I would certainly concede on your point if the OP was explicit that he indeed wanted MegaBytes (i.e. 1000 x 1000 Bytes). Dec 15 '17 at 3:42
  • PS @dhee - thanks for commenting why you downvoted. Whilst I still disagree, and stand by my above response to your comment, I commend your integrity! Upvote for your comment, despite the fact I disagree! :) Dec 15 '17 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.