pvscan
Scan for all present LVM physical volumes
TLDR
List all physical volumes
Show the volume group that uses a specific physical volume
Show logical volumes that use a specific physical volume
Display detailed information in JSON format
SYNOPSIS
pvscan [OPTIONS]
PARAMETERS
--devices
Specifies device(s) to scan. Using this limits scanning only to the specified paths, improving efficiency.
-u, --uuid
Displays the Universal Unique Identifier (UUID) of physical volumes in the output.
-v, --verbose
Increases the verbosity level of the output, showing more details about the scanning process.
-q, --quiet
Suppresses non-essential output, useful for scripting or when only errors are of interest.
-P, --partial
Allows the command to process physical volumes even if their LVM metadata is only partially available or corrupt.
-S, --select
Selects physical volumes based on specific criteria for reporting. This allows filtering PVs based on attributes like size, UUID, or belonging to a specific volume group.
-o, --options
Specifies a comma-separated list of fields to display in the output, allowing for custom reporting (e.g., pv_name,pv_size,vg_name).
--reportformat
Specifies the output format for the report, such as json or json+cols, enabling programmatic parsing of the output.
DESCRIPTION
The pvscan command is an essential component of the Logical Volume Manager (LVM) suite in Linux. Its primary function is to scan all block devices on the system for LVM physical volumes (PVs).
When executed, pvscan reads the metadata on these devices to identify any existing PVs. It then builds an in-memory list of these discovered LVM metadata areas. This list is crucial for other LVM commands (like vgscan or lvscan) to operate correctly, as they rely on pvscan to locate and understand the LVM structure across the system's storage.
pvscan is often run during system boot to ensure that LVM structures are properly recognized and accessible. It helps in detecting new physical volumes or refreshing the LVM's understanding of the current storage layout, especially after hardware changes or disk additions. Its output typically provides information about the PVs found, including their device paths, unique identifiers (UUIDs), and the volume groups they belong to.
CAVEATS
Running pvscan without any options will scan all available block devices, which can be time-consuming on systems with many disks or slow storage. It's primarily a scanning tool; it does not make changes to the LVM metadata or activate/deactivate volume groups or logical volumes directly (though some related options can influence activation behavior during a scan). Always ensure LVM tools are updated for compatibility with the latest LVM metadata formats.
METADATA SCANNING
pvscan primarily focuses on finding and reading LVM metadata headers located on block devices. These headers contain essential information about the physical volume, including its UUID, size, and which volume group it belongs to. Without this metadata, other LVM commands cannot correctly identify or manage the physical volume.
INTEGRATION WITH SYSTEM STARTUP
On many Linux distributions, pvscan (or equivalent LVM initialization steps) is automatically executed during system boot. This ensures that the LVM framework is aware of all physical volumes and their associated volume groups and logical volumes before higher-level services or user applications attempt to access them.
HISTORY
The pvscan command is an integral part of the original LVM (Logical Volume Manager) framework, which was first introduced in Linux kernel 2.4. Developed to provide flexible disk space management, LVM allows for dynamic resizing of partitions and easier volume management. pvscan has been a core utility since the early days of LVM, responsible for discovering the foundational physical volume components that make up LVM's storage hierarchy. Its functionality has remained consistent, evolving mainly with the addition of more sophisticated filtering, output formatting, and error handling options.