Inspect LVM Physical Volumes Safely with pvdisplay
In about 10 minutes, you will be able to identify an LVM physical volume, check its size and allocation state, and inspect which logical volumes use its physical extents. The examples are read-only: pvdisplay reports metadata and does not initialise, resize, move or remove a device.
The route
Jump straight to the step you need, or tick off Done means at the end.
Before you start
You need the lvm2 package and a device that is already an LVM physical volume. On this system the installed package is lvm2 2.03.16-3ubuntu3.2, reporting LVM version 2.03.16(2). Other releases can add fields or change formatting, so check the version before depending on exact output in a script.
Reading a local PV is usually an ordinary inspection task, but device discovery and LVM locking commonly need elevated privileges. Prefix the examples with sudo when your account cannot read the devices or acquire the LVM lock. Do not guess a device path: list the known PVs first with sudo pvs, or ask the system owner.
Checkpoint 1: confirm the tool and find the PV
- Check the installed version.
pvdisplay --version
Expected output begins with a line similar to this:
LVM version: 2.03.16(2) (2022-05-18)
Now identify a real PV path. If pvs is available, this is the most compact check:
sudo pvs -o pv_name,vg_name,pv_size,pv_free
Copy one value from the PV column, such as /dev/sdb2. Replace that example with your actual path in the commands below. A path that is not a PV will produce an error or no useful report; that does not make it safe to initialise.
Checkpoint 2: read the full PV report
- Display the attributes of one physical volume.
sudo pvdisplay /dev/sdb2
The report describes the PV size, physical extent size, space used by the volume-group descriptor area, and allocation. It also identifies the volume group when the PV belongs to one. The exact labels and spacing are presentation details; use the options below when another program needs stable columns.
To inspect several known PVs, put their paths after the command:
sudo pvdisplay /dev/sdb2 /dev/sdc1
Checkpoint: the paths in the report should be the devices you intended to inspect. If a PV appears missing, stop and investigate device visibility, multipath or the LVM devices file before changing metadata.
Use the small reports when you only need one fact
--short prints only the size of the supplied PVs. It is useful for a quick capacity check:
sudo pvdisplay --short /dev/sdb2
--units controls displayed sizes. Lower-case units use powers of 1024, while upper-case units use SI multiples of 1000. Human-readable output is the default style, but an explicit unit makes a transcript less ambiguous:
sudo pvdisplay --units g /dev/sdb2
sudo pvdisplay --units G /dev/sdb2
For machine processing, suppress suffixes and use a fixed unit. The input syntax is not the same as output syntax: numbers supplied as size arguments use base-two units, whereas --units G selects SI output.
sudo pvdisplay --units g --nosuffix /dev/sdb2
Checkpoint 3: inspect physical-to-logical mappings
- Ask for the mapping from physical extents on the PV to logical and physical extents.
sudo pvdisplay --maps /dev/sdb2
This is the useful view when a disk is nearly full or you need to understand which logical volume occupies a region. It is still an inspection command. Do not infer that an empty or surprising mapping authorises pvremove, pvmove or filesystem changes; those are separate operations with their own data-loss boundaries.
Choose output for scripts carefully
--colon produces colon-separated output. It is easier to split than the normal report, but it is still a format defined by this LVM release. If you need selected fields, headings, sorting or a more configurable report, use pvs, which the local manual recommends as the preferred alternative. Start by inspecting its available fields rather than assuming names:
sudo pvs --options help
sudo pvs --noheadings --separator '|' \
--options pv_name,vg_name,pv_size,pv_free
Do not parse aligned human output with fixed character positions. Names, sizes and spacing can change with device names and LVM version. For a quick one-off shell check, --noheadings and --separator on the report command can help, but validate the result against a known PV before automating an action.
Common failure modes
- Permission or locking warnings: rerun with
sudo. Do not use--nolockingcasually; the manual warns that concurrent commands can then produce incorrect results. - No PV is shown: verify the path, device visibility and any configured LVM devices file. A restricted view can make devices appear missing without changing the disk.
- A virtual machine is using the metadata:
--readonlyreads on-disk metadata without taking normal locks and does not communicate with the device-mapper driver. It cannot tell you whether logical volumes are actually in use, so treat it as a metadata peek, not proof that a device is safe to modify. - You expected a compact table: use
pvs.pvdisplayis a detailed display command, and its normal report is not intended as a stable API.
Done means
- You confirmed the installed LVM version.
- You used a verified PV path rather than guessing a disk.
- You checked size and allocation with
pvdisplay. - You used
--mapswhen physical extent placement mattered. - You kept inspection separate from commands that change metadata or move data.