I am looking through the various *fdisk and *parted utilities along with a few others. I am searching for a utility (or collection of utilities) that will list the size, in bytes, of all of the disks and partitions on a machine. Bonus points for any additional information on the drive or partition such as make/model/label/filesystem. It should also be able to report the size of drives with no partition table installed
- plain fdisk
- ✗ No GUID Partition Table support
- ✗ Not in bytes, no flags to allow for it
- sfdisk
- ✗ No GUID Partition Table support
- ✓ Flag to support Megabytes (close)
- parted
- ✓ Does support GPT
- ! Option to control unit only works on one disk at a time
- ✗ Rounds to largest possible unit
- lshw
- ✗ Doesn't show partition info
- ✗ Rounds to highest unit
- ✗ No option to control units
- pvdisplay / pvs
- ✗ Only works on disks that are part of LVM2 array
- ✗ Doesn't show disk info if partition is volume used in array
- ✓ Does have flags to set unit to bytes
-l
ignores all commands. – muru Dec 27 '14 at 05:13parted
doesn't seem to print labels. So you'll probably need to use something likelsblk
, and so while you're using it, you could loop over the entries of typedisk
in its output. – muru Dec 27 '14 at 05:17lsblk -ba
does what I want, even tells me which volumes are used in which lvm logical volumes. Submit that as an answer and I'll accept it. – Huckle Dec 27 '14 at 06:00lsblk
as well. – muru Dec 27 '14 at 08:47lsblk
is infuriating! The output table from either the-l
or the-i
invocations are not delimited, they're fixed width. That wouldn't be so bad, except that headers for purely numeric columns (size, MIN-IO) have right justified headers while all the others are left justified. This makes it nearly impossible to determine the column widths. – Huckle Dec 27 '14 at 21:02sudo parted <<<'unit B p all q'
– muru Dec 31 '14 at 11:04Error: /dev/sda: unrecognised disk label
and stops printing. – Huckle Jan 01 '15 at 21:25