pvdisplay Command in Linux



The pvdisplay command in Linux displays the various attributes of the physical volumes. It provides information such as the PV size, UUID, volume group association, and allocation details. It helps in managing LVM storage by identifying volume details, tracking allocations, troubleshooting issues, and planning expansions.

Table of Contents

Here is a comprehensive guide to the options available with the pvdisplay command −

Syntax of pvdisplay Command

The syntax of the pvdisplay command in Linux is as follows −

pvdisplay [options] [physical_volume…]

In the above syntax, the [options] field is used to specify the options to modify the command's output. The [physical_volume] field is used to specify one or more device names ( example: /dev/sdX) to display their information.

pvdisplay Command Options

The common options of the Linux pvdisplay command are listed below −

FlagsOptionsDescription
-a--allShow information about devices that have not been initialized by LVM
-c--colonGenerate colon-separated output for easier parsing
-C--columnsDisplay output in columns, like vgs
--commandprofile stringThe command profile to use for configuration
--config stringOverride settings from lvm.conf
--debugSet debug level, repeat 1-6 times to increase detail
--devices PVList of devices to be used by the command
--devicesfile stringFile listing devices for LVM to use
--driverloadedControl device-mapper usage for testing and debugging
--foreignReport foreign VGs that would otherwise be skipped
-h--helpDisplay help text
--ignorelockingfailureAllow read-only operations after locking failures
--journal stringRecord information in systemd journal
--lockopt stringPass options for special cases to lvmlockd
--logonlySuppress report and display only log information
--longhelpDisplay extended help text
-m--mapsDisplay mapping of physical extents to logical volumes
--nohintsDo not use hints file to locate devices for PVs
--nolockingDisable locking
--nosuffixSuppress suffix on output sizes
-o string--options stringComma-separated list of fields to display
--profile stringAlias for --commandprofile or --metadataprofile
-q--quietSuppress output and log messages
--readonlyRun command in read-only mode
--separator stringSpecify a string to separate columns
--sharedReport shared VGs that would otherwise be skipped
-s--shortOnly display the size of the given PVs
-O string--sort stringComma-separated list of columns to sort by
-t--testRun in test mode without updating metadata
--unbufferedProduce output immediately without sorting/aligning columns
--units [number]Set units for size output
-v--verboseSet verbose level to increase message detail
--versionDisplay version information
-y--yesAutomatically assume yes for prompts

Examples of pvdisplay Command in Linux

In this section, the usage of the pvdisplay command in Linux will be discussed with examples −

  • Displaying Details of All Physical Volumes (PVs)
  • Displaying Colon Separated Output
  • Displaying Output in Columnar Format
  • Displaying Output in Short Format
  • Displaying Mapping of Physical Extents
  • Displaying Output in Verbose
  • Displaying Output in Different Units
  • Running the pvdisplay Command in Test Mode
  • Recording Information to the Journal
  • Displaying Usage Help

Displaying Details of All Physical Volumes

To show detailed information about all physical volumes (PVs) in the system, including their size, volume group, and allocation status, use the pvdisplay command with sudo −

sudo pvdisplay
pvdisplay Command in Linux1

The output displays the PV Name, VG Name, PV Size, Free PE and information about other attributes as shown in the above image.

To display information of a specific PV, use the pvdisplay command in the following way −

sudo pvdisplay /dev/vda3

Displaying Colon Separated Output

To display colon separated output, use the -c or --colon option −

sudo pvdisplay -c
pvdisplay Command in Linux2

The above command generates colon-separated output for easier parsing.

Displaying Output in Columnar Format

To display the PV details in columnar format, use the -C or --columns option −

sudo pvdisplay -C
pvdisplay Command in Linux3

Displaying Output in Short Format

To display the PV details in columnar format, use the -s or --short option −

sudo pvdisplay -s
pvdisplay Command in Linux4

The above command will only show the size of the physical volumes, without any other details.

Displaying Mapping of Physical Extents

The -m or --maps option in the pvdisplay command displays the mapping of physical extents (PEs) to logical volumes (LVs) and logical extents (LEs).

sudo pvdisplay -m
pvdisplay Command in Linux5

Displaying Output in Verbose

To get the verbose output, use the -v or --verbose option with the pvdisplay command −

sudo pvdisplay -v

To get even more detailed output increase the verbosity level (-vv) −

sudo pvdisplay -vv
pvdisplay Command in Linux6

Displaying Output in Different Units

The --units option in the pvdisplay command allows to specify the units in which the sizes should be displayed, making it easier to read large numbers.

By default, the output of pvdisplay is in GiBs. To get the output in MiBs, use the pvdisplay command in the following manner −

sudo pvdisplay --units g
pvdisplay Command in Linux7

A list of units that can be used with the --units option is as follows −

r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E

Running the pvdisplay Command in Test Mode

To dry run the pvdisplay command, use the -t or --test option −

sudo pvdisplay -t

Recording Information to the Journal

To record information about the command in the systemd journal, use the --journal option with the pvdisplay command. For example, to journal debug details, use the following command −

sudo pvdisplay --journal debug

Other logging levels that can be recorded can be defined using following flags −

  • command − Records information about the commands being executed.
  • output − Records the output generated by the command.
  • log − Records general logging information.
  • all − Records all types of information, including command, output, log, and debug details.

Displaying Usage Help

To display usage help of the pvdisplay command, use the -h or --help option −

pvdisplay -h

To display the detailed help, use the --longhelp option −

pvdisplay --longhelp

Conclusion

The pvdisplay command in Linux is essential for managing and troubleshooting LVM (Logical Volume Manager) storage by displaying detailed information about physical volumes. It shows various attributes such as the size, UUID, and volume group association, helping in tracking storage allocations and planning for expansions.

This command offers a variety of options, including displaying output in different formats, showing verbose details, and specifying units for size output. It also allows for advanced functionalities like mapping physical extents to logical volumes and recording information in the systemd journal.