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?
Asked
Active
Viewed 4.5k times
11
Andrew Tobey
- 253
- 1
- 2
- 7
-
You might want to look at some of the alternatives to `fdisk -l` here. http://serverfault.com/questions/190685/whats-the-best-way-to-get-info-about-currently-unmounted-drives/190700?noredirect=1#comment744104_190700 – Zoredache Aug 14 '14 at 20:11
2 Answers
17
You can't. Use something else like parted -l
instead.
See man parted
for more information.
-
thx. So GPT is what Microsoft grants us with by introducing Windows 8? – Andrew Tobey Aug 14 '14 at 18:19
-
4GPT 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. http://en.wikipedia.org/wiki/GUID_Partition_Table – Broco Aug 14 '14 at 18:50
-
-
@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 09: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: http://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: http://git.kernel.org/cgit/utils/util-linux/util-linux.git/commit/?id=766d5156c43b784700d28d1c1141008b2bf35ed7 – Jeremy Davis Nov 20 '15 at 04:58
-
Correction to my last comment; I'm not actually sure what version of fdisk is in Debian Jessie; but it is a part of the 'essential" util-linux package which is v2.25.2... – Jeremy Davis Nov 20 '15 at 05:09
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
Jeremy Davis
- 396
- 3
- 14
-
+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. – Benoit Duffez May 12 '17 at 09:12
-
2
-
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). – Jeremy Davis Dec 15 '17 at 03: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! :) – Jeremy Davis Dec 15 '17 at 05:12