I want to automate some maintenance actions, and I need to be able to request some details about LVM objects in my scripts.

In particular, I need to be able to request at least the PE size in bytes and how many free PEs is available on the certain PV.

There is some progress, e.g. pvdisplay --units b --nosuffix shows data in bytes and without garbage.

However, I hoped that I won't be required to parse this output much (with grep/awk/etc.), and I can make pvdisplay and other LVM utilities to output exactly the data I need. I think that would be more robust. There is an option -o/--options which should filter the output, according to the man pvdisplay. The manual page also says that the list of available fields for use with -o could be obtained by running with -o help. Nevertheless, -o help and anything else with -o always outputs:

  Incompatible options selected
  Run `pvdisplay --help' for more information.

That's all. There is even a bug in Fedora bugzilla, closed without solution due to EOL of the version for which it was reported.

Is it possible to output only certain information, or should I resort to parsing a standard LVM output?

1 Answer 1


The {pv,lv,vg}display --options parameter seems to only work in conjunction with --columns, equivalent to the shorthand pvs, vgs, lvs commands.

the PE size in bytes

# vgs -o vg_extent_size --units b VGNAME

how many free PEs is available

# pvs -o pv_pe_count,pv_pe_alloc_count /dev/PV

or alternatively

# pvs -o pv_free --units b /dev/PV

If you don't want to specify the VG / PV directly, add name to the options.

There are additional options that might help with parsing, e.g. --noheadings, --nosuffix, --separator=:, --rows, --quiet or --reportformat=json. Yet another option would be to parse the output of pvdisplay --colon.

  • Nowhere it was said it has to be used like that! Anyway, thank you, that's what I was asking for, pvs -o pv_free --noheadings --units b --nosuffix --separator= PV (there's a space after "=") and friends do the trick. Commented Sep 9, 2022 at 3:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .