pvscan Command in Linux



The pvscan command in Linux scans all the physical volumes (PVs) on the system and displays their status. It helps identify which physical volumes belong to a volume group (VG) and their available space. It is also useful for detecting, analyzing, and managing physical volumes (PVs) in Linux, ensuring proper logical volume management (LVM) operations.

Table of Contents

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

Syntax of pvscan Command

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

pvscan [options]

In the above syntax, the [options] field is used to specify the options to modify output format, filter data, or provide additional details.

pvscan Command Options

The options of the Linux pvscan command are listed below −

Flags Options Description
-a y|n|ay --activate y|n|ay Automatically activates logical volumes (LVs) in a volume group (VG) when all its physical volumes (PVs) are available. Only ay (auto-yes) is valid.
--autoactivation String Used for event-based autoactivation and optimizations.
--cache Scan devices and record them as online.
--checkcomplete Check if all devices for a VG/LV are present.
--commandprofile String Specify the command profile for configuration.
--config String Override lvm.conf settings for this command.
-d --debug 1-6 Set debug level (1-6 for increasing detail).
--devices PV Specify devices for the command (comma-separated list).
--devicesfile String Specify a file listing devices for LVM.
--driverloaded y|n Prevent the use of a device-mapper (for testing/debugging).
-e --exported Show PVs belonging to exported VGs.
--ignorelockingfailure Continue with read-only metadata after locking failures.
--journal String Record command details in the systemd journal.
--lockopt String Pass special options to lvmlockd.
--longhelp Display extended help text.
--nohints Ignore the hints file when locating PVs.
--nolocking Disable the locking mechanism.
--noudevsync Disable udev synchronization.
-n --novolumegroup Show PVs not belonging to any VG.
--profile String Alias for --commandprofile or --metadataprofile.
-q --quiet Suppress output and log messages.
--reportformat basic|json Set report output format.
-s --short Use a short listing format.
-t --test Run in test mode without updating metadata.
--udevoutput Modify output for udev rules.
-u --uuid Display UUIDs along with device names.
-v 1-4 --verbose 1-4 Set verbosity level (1-4 for more detail).
--version Show version information.
--vgonline Mark the first command to see a complete VG uniquely.
-y --yes Always assume yes for confirmations (use with caution).
-h --help Display help text.

Examples of pvscan Command in Linux

This section demonstrates the usage of the pvscan command in Linux with examples −

  • Scanning all the Physical Volumes (PVs)
  • Scanning Physical Volumes (PVs) in Test Mode
  • Scanning Physical Volumes (PVs) and Displaying Information in JSON
  • Scanning Physical Volumes (PVs) and Recording as Online
  • Scanning Physical Volumes (PVs) and Displaying them in a Short Format
  • Scanning Physical Volumes (PVs) and Displaying them with UUID
  • Recording Logs
  • Disabling Device Mapper
  • Scanning Physical Volumes (PVs) with No Volume Group
  • Displaying Usage Help

Scanning all the Physical Volumes (PVs)

To display all detected PVs, their volume groups (VGs), and available space, use the pvscan command with sudo −

sudo pvscan
pvscan Command in Linux1

Scanning Physical Volumes (PVs) in Test Mode

To scan and display all PVs in test mode, use the -t or --test option with the pvscan command −

sudo pvscan -t
pvscan Command in Linux2

The above command runs in test mode without updating metadata.

Scanning Physical Volumes (PVs) and Displaying Information in JSON

To scan all the physical volumes (PVs) on the system and display information in JSON format, use the --reportformat option −

sudo pvscan --reportformat json

Scanning Physical Volumes (PVs) and Recording as Online

To scan all the devices and record them as they are online, use the --cache option with the pvscan command −

sudo pvscan --cache
pvscan Command in Linux3

Scanning Physical Volumes (PVs) and Displaying them in a Short Format

To scan all PVs and display them in a short format, use the -s or --short option −

sudo pvscan -s
pvscan Command in Linux4

Scanning Physical Volumes (PVs) and Displaying them with UUID

To display the UUIDs along with the physical volumes (PVs) to the output, use the -u or --uuid option −

sudo pvscan -u
pvscan Command in Linux5

Recording Logs

The --journal option records command-related information in the systemd journal, which can help with debugging or logging. Types of information that can be recorded are listed below −

  • command − Records information about the command execution.
  • output − Logs the default command output.
  • debug − Captures full command debugging details.

To log output information, use the pvscan command in the following way −

sudo pvscan --journal output

Disabling Device Mapper

The pvscan will not attempt to use the device mapper when the --driverloaded option is set to NO.

sudo pvscan --driverloaded n
pvscan Command in Linux6

Scanning Physical Volumes (PVs) with No Volume Group

To scan and display PVs that do not belong to any volume group, use the -n or --novolumegroup option −

sudo pvscan -n

Displaying Usage Help

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

pvscan -h

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

pvscan --longhelp

Conclusion

The pvscan command in Linux scans all physical volumes (PVs) on a system and provides information about their status, volume group (VG) association, and available space. Various options modify its output, allowing actions like auto-activation, filtering, debugging, and different output formats.

Common uses include scanning PVs, running in test mode, displaying JSON-formatted results, recording logs, and managing device-mapper interactions. Example commands demonstrate how to list PVs, check UUIDs, enable caching, and access help documentation.

Advertisements