Audit LVM Volume Groups with vgs
You will finish with a repeatable way to inspect LVM volume groups, choose the columns that matter, and hand the result to a shell script or monitoring check. The examples use the LVM tools 2.03.16(2) installed with this guide. Allow about 10 minutes for a first audit, plus time to investigate any missing groups.
The route
Jump straight to the step you need, or tick off Done means at the end.
Before you start
You need the vgs command from the lvm2 package. Reading metadata is normally a privileged administration task, so run the commands as root or through sudo when your host requires it. Nothing in this guide changes LVM metadata, but a restricted user may see warnings or an incomplete report.
Start by recording the installed version. This matters because report fields and defaults can differ between LVM releases.
vgs --version
On this machine the relevant lines are:
LVM version: 2.03.16(2) (2022-05-18)
Library version: 1.02.185 (2022-05-18)
Checkpoint: get the normal inventory
Run vgs with no volume-group argument to list the groups visible to LVM. The usual report includes the group name, physical-volume count, logical-volume count, size, and free space. The command is a report, not a create, extend, or remove operation.
sudo vgs
To request one known group, put its name after the options:
sudo vgs vg_data
A name can also be a tag. If a group appears to be absent, do not immediately edit configuration or scan random devices. Visibility may be restricted by the device filter, a devices file, locking, or the group being foreign to this host. Check the warnings first.
Choose stable columns
The default display is convenient for a person but awkward for scripts. Use --options with a comma-separated list. These fields are a useful capacity audit:
sudo vgs --options vg_name,vg_uuid,vg_size,vg_free,pv_count,lv_count
The field order is the order you request. Ask the installed command for the complete field list rather than assuming a field from a different release:
vgs --options help
Use --noheadings when another program will consume the rows, and --separator to make the boundary explicit.
sudo vgs --noheadings --separator '|' \
--options vg_name,vg_size,vg_free,pv_count,lv_count
Expected output on a host with a group resembles this shape. Values and spacing depend on the host, so treat it as a format example, not a promised inventory:
vg_data|<size>|<free>|<pv-count>|<lv-count>
For machine parsing, also consider JSON. The report format is controlled globally by LVM configuration, so specify it when a consumer depends on it.
sudo vgs --reportformat json --options vg_name,vg_size,vg_free
Make sizes unambiguous
Human-readable sizes are useful at a terminal, but suffixes and binary units can surprise arithmetic. Select a unit explicitly. Lowercase units use powers of 1024; uppercase units use SI multiples of 1000. Bytes are a straightforward choice for a parser.
sudo vgs --units b --nosuffix \
--noheadings --separator '|' \
--options vg_name,vg_size,vg_free
--nosuffix only makes sense with a chosen unit, apart from the human-readable modes. Without it, values can include a unit suffix. The r human-readable mode can add a less-than sign to indicate rounding; use h when you want human-readable output without that rounding indicator.
Filter and sort the report
Use --select for report-side filtering. Its expression language is specific to LVM, so inspect the fields and selection help on the installed version before building a larger expression.
vgs --select help
vgs --options help
A simple example asks for groups with free space below a chosen threshold. The exact comparison and size syntax should be tested against the fields available on your host before putting it in an alert:
sudo vgs --select 'vg_free < 10g' \
--options vg_name,vg_size,vg_free
Sort explicitly when output is compared over time. Prefix a column with a minus sign for reverse order.
sudo vgs --sort -vg_free --options vg_name,vg_free
Checkpoint: investigate missing groups safely
First compare the default inventory with all groups:
sudo vgs --all
The manpage defines --all as equivalent to omitting a group argument. It does not bypass every visibility rule. --foreign includes volume groups that LVM would otherwise skip because their system identity belongs elsewhere. Use it for inspection, not as a reason to activate or modify a foreign group.
sudo vgs --foreign --options vg_name,vg_systemid,vg_size,vg_free
If your installation uses the LVM devices file, --devicesfile NAME selects a file under /etc/lvm/devices/, and --devices /dev/DEVICE restricts the devices visible to the command. A restricted device list can make a healthy group look incomplete or missing. Confirm the intended devices before diagnosing metadata damage.
For a read-only inspection of on-disk metadata, --readonly avoids taking locks and does not communicate with the device-mapper kernel driver. That makes it useful for examining metadata associated with an image while a virtual machine is running, but it cannot tell you whether logical volumes are currently in use.
sudo vgs --readonly --reportformat json \
--options vg_name,vg_uuid,vg_size,vg_free
Warnings and unsafe shortcuts
Do not add --nolocking to make a warning disappear. The manual warns that concurrent commands can then produce incorrect results. Likewise, --ignorelockingfailure permits some read-only metadata operations after a locking failure, but it is not a repair and should not hide a cluster or shared-storage problem.
The --shared option reports shared groups that would otherwise be skipped when lvmlockd is not being used. Use it only when you understand the host's shared-volume arrangement. --foreign, --shared, device restrictions, and read-only mode change what the report means; record the options with any exported result.
Although vgs is a reporting command, common LVM options include --yes and --test. Do not copy those options into a generic command template. --yes suppresses confirmation prompts and is hazardous when reused with a different LVM command. --test disables metadata writing, but the manual warns that multi-stage tools can still produce unusual messages. Neither option repairs a failed report.
Done means
vgs --versionis recorded with the audit.- The normal report and, where needed,
--allor--foreignhave been compared. - Script output names its fields, uses an explicit separator or JSON, and specifies units when arithmetic is involved.
- Any device-file, locking, shared-group, or foreign-group warning has been investigated before changing LVM configuration.
- No report command was confused with an activation, repair, resize, or removal operation.