
pvs Command in Linux
The pvs command in Linux displays information about the physical volume. It provides a summary of all physical volumes in a system, showing details such as the volume name, volume group, size, and usage. It is a part of LVM (Logical Volume Manager) and is useful for monitoring storage and managing logical volumes efficiently.
Table of Contents
Here is a comprehensive guide to the options available with the pvs command â
Syntax of pvs Command
The syntax of the pvs command in Linux is as follows −
pvs [options] [physical_volumeâ¦]
In the above syntax, the [options] field is used to specify the options the modify output format, filter data, or provide additional details. The [physical_volumeâ¦] is used to specify one or more PV or device paths.
pvs Command Options
The options of the Linux pvs command are listed below −
Flags | Options | Description |
---|---|---|
-a | --all | Show information about devices that are not initialized as PVs. |
--binary | Use binary values (0 or 1) instead of descriptive literals. | |
--commandprofile Str | Use a command profile for configuration. | |
--config Str | Override lvm.conf(5) settings. Supports section/field syntax. | |
--configreport log|vg|lv|pv|pvseg|seg | Customize report format. | |
-d | --debug | Set debug level (repeat up to 6 times for more detail). |
--devices PV | Specify devices the command can use (comma-separated list). | |
--devicesfile Str | Use a file in /etc/lvm/devices/ to specify allowed devices. | |
--driverloaded y|n | Skip device-mapper interaction if set to no. Useful for debugging. | |
--foreign | Display foreign volume groups (VGs). | |
-h | --help | Display help text. |
--ignorelockingfailure | Continue with read-only metadata operations after locking failures. | |
--journal Str | Record additional information in the system journal. | |
--lockopt Str | Pass options to lvmlockd. | |
--logonly | Suppress command report, and display only log messages. | |
--longhelp | Display extended help text. | |
--nameprefixes | Add LVM2_ prefix to field names for easy scripting. | |
--noheadings | Remove column headers from output. Useful for scripts. | |
--nohints | Disable hints file when locating PVs. | |
--nolocking | Disable locking mechanism. | |
--nosuffix | Remove unit suffixes from size outputs. Works with --units. | |
-o | --options Str | Customize output fields. Use -o help to list available fields. |
--profile Str | Alias for --commandprofile or --metadataprofile. | |
-q | --quiet | Suppress log messages. Repeat for silent mode. |
--readonly | Run the command in read-only mode, avoiding metadata locks. | |
--reportformat basic|json | Change report format (default: basic, or JSON). | |
--rows | Display output columns as rows. | |
--segments | Show contiguous space allocations on each PV. | |
-S | --select Str | Filter results based on selection criteria. |
--separator Str | Specify column separator (useful for CSV output). | |
--shared | Display shared VGs even when lvmlockd is not used. | |
-O | --sort Str | Sort output by specified columns. Prefix with - for reverse sort. |
-t | --test | Run the command in test mode without modifying metadata. |
--unbuffered | Disable output buffering, showing results immediately. | |
--units [Num] | Define output units (bytes, KB, MB, etc.). | |
--unquoted | Remove quotes when using --nameprefixes. | |
-v | --verbose | Increase verbosity (repeat up to 4 times for more detail). |
--version | Show version information. | |
-y | --yes | Automatically confirm all prompts with yes (use with caution). |
Examples of pvs Command in Linux
In the section, the usage of the pvs command in Linux will be discussed with examples −
- Displaying all Physical Volumes (PVs)
- Displaying Physical Volumes (PVs) without Column Headers
- Displaying a Specific Field
- Displaying All Devices not Initialized as PVs
- Sorting Physical Volumes (PVs)
- Displaying Output in JSON Format
- Displaying Segment Allocation Details
- Displaying Output in a Specific Unit
- Suppressing Unit Suffix
- Displaying Physical Volumes (PVs) with Field Names Prefixed
- Displaying Output in Rows
- Displaying Usage Help
Displaying all Physical Volumes (PVs)
To display all physical volumes, use the pvs command without any option −
sudo pvs

Displaying Physical Volumes (PVs) without Column Headers
To display all physical volumes without column headings, use the --noheadings option −
sudo pvs --noheadings

The above command removes the first line of headers from the output, useful for scripts.
Display Specific Fields
To display a specific field, use the -o or --option with the pvs command. For example, to show only the PV name and size columns.
sudo pvs -o pv_name,pv_size

To display all the available options, run the following command −
sudo pvs -o help

Displaying All Devices not Initialized as PVs
To show information about devices that are not initialized as physical volumes (PVs), use the -a or --all option with the psv command −
sudo pvs -a

Sorting Physical Volumes (PVs)
Use the -O or --sort option to sort the physical volumes. For example, to sort the PVs by size in ascending order, use the following command −
sudo pvs -O pv_size
To sort in descending or use a dash (- reverses the order) with pv_size option −
sudo pvs -O -pv_size
Displaying Output in JSON Format
To display the output in JSON format, use the --reportformat option −
sudo pvs --reportformat json

Displaying Segment Allocation Details
To display the segment allocation details, use the --segments option with the pvs command −
sudo pvs --segments

Displaying Output in a Specific Unit
To display the output in a specific unit, use the --units options. To display output in gigabytes, use g with the --units option −
sudo pvs --units g

Other units that can be used are listed below −
- b (bytes), s (sectors), k (kilobytes), m (megabytes), t (terabytes), p (petabytes), e (exabytes)
- Capitalized versions (K, M, G, etc.) use SI units (base 1000 instead of 1024).
Suppressing Unit Suffix
To suppress the unit suffix from the output, use the --nosuffix option −
sudo pvs --nosuffix --units M

The above command outputs sizes in megabytes without unit symbols.
Displaying Physical Volumes (PVs) with Field Names Prefixed
To display the PVs with field names prefixed, use the --nameprefixes option −
sudo pvs --nameprefixes

The above command displays fields as LVM2_field=value, useful for parsing in scripts.
Displaying Output in Rows
By default, the output is displayed in the columns. To display the output in row format, use the --rows options
sudo pvs --rows

Displaying Usage Help
To display usage help of the pvs command, use the -h or --help option −
pvs -h
Conclusion
The pvs command in Linux is used to display information about physical volumes in a system, providing details such as volume name, volume group, size, and usage. It is an essential tool for managing and monitoring storage in a system using LVM (Logical Volume Manager). Various options and syntax allow customization of the output, such as sorting, filtering, and displaying in different formats.