System and processes

The pvs command

Summarizes LVM physical volumes: group, size and free space in one table.

Most useful options

-a, --allAlso shows devices that LVM has not yet initialized as PVs
-o, --options <campos>Chooses the columns, comma separated. With + you add columns to the defaults and with - you remove them. Use -o help to list them
-S, --select <criterio>Shows only the rows that match a criterion. Its syntax is in pvs --select help
-O, --sort <columnas>Sorts by the given columns. A leading - reverses the order of that column
--units <unidad>Shows sizes in a fixed unit. In lowercase (g, m) they are powers of 1024; in uppercase, powers of 1000
--noheadingsDrops the header line, handy for looping over the output
--reportformat basic|jsonSwitches the output to JSON, convenient for programs that read it

Copy-ready examples

$ pvssummary of all the physical volumes on the machine.
$ sudo pvs -o pv_name,vg_name,pv_size,pv_freeonly the columns you need: device, group, size and free space.
$ sudo pvs -o +pe_startadds the start of the first physical extent to the default columns.
$ sudo pvs --noheadings -o pv_name,pv_freeno header and two columns, ready to be processed in a script.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
Failed to find physical volume "/dev/sdz".The device does not exist or LVM does not recognise it as a PV. pvs only shows physical volumes.List the disks with lsblk and check the name. If the disk is new, prepare it with pvcreate.

Typical mistakes

  • If a disk does not appear, it is not prepared: pvs only lists devices that LVM recognises as PVs, unless you use -a.
  • The VG column stays empty until the PV joins a group with vgcreate or vgextend.
  • With -o alone, the list replaces the default one; with +field, it adds to it.
  • pvs only reports and changes nothing: use it freely to check the state before any change.

Differences from similar commands

  • pvdisplay: gives the same information in detail blocks. The pvdisplay manual page itself recommends pvs.
  • vgs: summarizes volume groups. pvs summarizes the physical disks that make them up.
  • lsblk: shows all disks and partitions, whatever they are used for. pvs only lists those LVM recognises as PVs, unless you use -a.

FAQ

Which columns does pvs show by default?

PV, VG, Fmt, Attr, PSize and PFree: the device, its group, the metadata format, the attributes, the size and the free space. Use -o help to see every field.

How do I get a PV's size in gigabytes without the unit?

With sudo pvs --units g --nosuffix -o pv_name,pv_size. You get only the number, in gibibytes.

Can I use pvs in a script?

Yes: combine --noheadings, --separator and -o for predictable columns, or --reportformat json if you prefer JSON.

More System and processes commands

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course