LinuxCommandLibrary

vgscan

Scan for volume groups

TLDR

Scan for volume groups and print information about each group found

$ sudo vgscan
copy

Scan for volume groups and add the special files in /dev, if they don't already exist, needed to access the logical volumes in the found groups
$ sudo vgscan --mknodes
copy

SYNOPSIS

vgscan [-v] [-a] [-i] [-M] [-p] [-q] [-t] [--version] [-h|--help] [--config 'Config Variable'] [--drivermanaged vgname] [--lockopt string] [--longhelp] [--profile ProfileName] [--reportformat {basic|json}] [--separator String] [--showcmd] [--showresults] [--test] [--type volume|snapshot|origin] [--usage] [--verbose] [Device]

PARAMETERS

-v
    Verbose output. Displays more details about the scanning process.

-a
    Scan all disks.

-i
    Interactive mode. Asks for confirmation before creating LVM metadata.

-M
    Do not use the device mapper.

-p
    Preview the changes without actually making them.

-q
    Quiet mode. Suppresses most output.

-t
    Test mode. Simulate the scan without making any actual changes.

--version
    Display the LVM version.

-h, --help
    Display help text.

--config 'Config Variable'
    Use specified configuration variable.

--drivermanaged vgname
    Only scan Volume Groups which are driver managed (requires the VG name as parameter).

--lockopt string
    Options for external locking.

--longhelp
    Display long help text.

--profile ProfileName
    Use a ProfileName configuration profile.

--reportformat {basic|json}
    The type of report requested is basic or json.

--separator String
    String to use when separating fields.

--showcmd
    Show the commands that are being executed.

--showresults
    Show the results of executed commands.

--test
    Run in test mode.

--type volume|snapshot|origin
    Type of volume to be scanned.

--usage
    Display usage text.

--verbose
    Provide verbose output.

Device
    Specific Device to scan.

DESCRIPTION

vgscan scans all disks and other storage devices for LVM physical volumes (PVs). It reads the PV headers to identify volume groups (VGs) and logical volumes (LVs). When a VG is discovered that isn't already known to the system, vgscan creates entries for it in the LVM system files within /etc/lvm/. This makes the VG and its LVs available for activation and use. vgscan is essential for systems where LVM configuration might change dynamically, or where LVM metadata on the disks might not match the system's current configuration. It is frequently run during system boot to ensure that all VGs are recognized and ready for use. Running vgscan periodically, or after adding new storage, is crucial for LVM to function correctly. Correct usage of this command is vital for any Linux system using LVM, as it ensures that all volume groups are correctly recognized and available.

CAVEATS

Running vgscan on a large number of disks can take a significant amount of time. Ensure that the disks are correctly configured and accessible to the system before running the command. Running without the -p option will apply any found changed immediately.

TYPICAL USE CASES

vgscan is typically executed during system startup (often via an init script or systemd unit) to ensure all LVM volume groups are recognized. It is also used after adding new disks or reconfiguring existing storage to update LVM's metadata. Periodic execution is recommended to maintain the consistency of the LVM setup.

ERROR HANDLING

If vgscan fails to detect a VG, check the physical connectivity of the disks and ensure that the LVM metadata is intact. Corrupted metadata can often be repaired using LVM recovery tools, but data loss is possible.

HISTORY

vgscan is a component of the Linux LVM2 (Logical Volume Manager 2) suite. Development began in the early 2000s as a more robust and feature-rich replacement for the original LVM. It is essential for detecting and managing LVM volumes and is included in every Linux distribution with LVM support. Its development mirrored LVM2's evolution, incorporating advanced features and improvements in storage management.

SEE ALSO

pvscan(8), lvscan(8), vgchange(8), lvm(8)

Copied to clipboard