Home / Alt manpages / lvm(8)

  • lvm(8)
  • Admin command
  • linux

Use lvm as a Safe Entry Point for LVM2 Administration

You will finish with a repeatable way to inspect LVM2, understand where its configuration comes from, and choose the right command before touching a physical volume, volume group or logical volume. The examples are read-only and should take about 10 minutes. Storage changes need a separate maintenance plan and a root shell.

Before you start

Install the lvm2 package and work on a host where you can read its configuration. The examples below were checked with LVM version 2.03.16(2), library version 1.02.185, from the Ubuntu package lvm2 2.03.16-3ubuntu3.2. Other releases can add commands or settings, so treat the local output as authoritative.

Most inspection commands can be run as an ordinary user, although LVM may warn that some functionality is unavailable. Commands that scan devices or change storage commonly need elevated privileges. Prefix only the command that needs it with sudo; do not make an entire shell root without a reason.

Checkpoint 1: confirm the entry point and version

lvm is the common LVM2 command-line entry point. Its built-in command list includes reporting commands such as pvs, vgs and lvs, storage operations such as pvcreate and vgcreate, and configuration tools such as lvmconfig. Each has its own manual page for options and safety rules.

lvm version
lvm help

Look for a version line and an available-command list. A non-root warning is expected on some hosts. The version command does not create or resize a device, so it is a useful first check before copying examples from another machine.

Checkpoint 2: inspect the storage view without changing it

Use the reporting commands directly when you need the state of LVM objects. The full path of a logical volume is optional: a logical volume named data in a group named vg0 can be written as vg0/data. An omitted volume-group list can mean all volume groups, so read a command's specific manual page before broadening a query on a production host.

sudo pvs
sudo vgs
sudo lvs

These commands report physical volumes, volume groups and logical volumes. Empty output is not proof that LVM is broken: it can mean that the host has no visible objects, that device access is restricted, or that the relevant devices are not available in the current environment. If a command fails, preserve the complete error and check journalctl or the device-management documentation before retrying.

Safety boundary

Do not substitute pvcreate, vgcreate, lvcreate, lvremove or lvreduce while experimenting. Initialising a device, removing an LV or reducing its size can destroy data. The lvm(8) page is an index, not a replacement for the manual page for the operation you intend to perform.

Checkpoint 3: see which configuration is active

LVM loads /etc/lvm/lvm.conf during initialisation. This can load other files, and LVM checks file timestamps between commands so changed files are reloaded. The companion /etc/lvm/lvmlocal.conf is also part of the configuration model. Start with the effective values instead of guessing what a sample configuration says.

lvmconfig --type current
lvmconfig --type diff
lvmconfig --type default --withcomments global/umask

current shows configured values that LVM is using, while diff narrows this to values different from defaults. The final command asks for one setting, its default and its description. If your installed release does not recognise a setting, stop and read that release's lvmconfig(8) documentation rather than copying a newer configuration.

The local configuration uses sections and assignments. Whitespace is not significant outside quotes, comments begin with #, strings with spaces need double quotes, and an empty array is valid.

devices {
    issue_discards = 1
}

This is an example of syntax, not a recommendation to enable discards. Device and allocation settings can affect performance, thin provisioning and data recovery. Change them only after checking their setting-specific documentation and recording the previous value.

Checkpoint 4: understand overrides and profiles

When multiple configuration methods supply the same setting, LVM applies a cascade. A direct command-line override is followed by a command profile, metadata profile, tag configuration, lvmlocal.conf and finally lvm.conf. If none supplies a value, LVM uses its default. This explains why editing lvm.conf may appear to do nothing.

A command profile applies selected settings for the whole command and is selected with --commandprofile ProfileName. A metadata profile belongs to a volume group or logical volume and can be retained in its metadata. It is selected during creation or attached later with the relevant vgchange or lvchange options. The reporting commands can show attached profile names:

sudo vgs -o vg_name,vg_profile
sudo lvs -o vg_name,lv_name,lv_profile

Profiles live in /etc/lvm/profile by default and are referenced without the .profile suffix. Command-profile and metadata-profile settings are separate sets. Mixing settings from the wrong set makes LVM reject the profile. Generate or inspect a template with lvmconfig before editing a profile, and keep a copy of the old file so you can restore it if validation fails.

Using the built-in shell and scripts

Running lvm with no arguments opens an interactive prompt when editline support is available. This can be convenient for repeated inspection because configuration information is cached between commands. It can also hide which command produced a result, so use ordinary commands in runbooks and automation.

You can pass a file containing one LVM command per line, or execute such a file when its first line is a shebang containing the absolute path to lvm. Keep scripted files read-only while testing, and make destructive steps explicit rather than relying on an interactive history.

Recovery and verification

If a configuration edit produces an error, restore the previous file from your change-control copy, then rerun lvmconfig --type current. LVM keeps metadata archives in /etc/lvm/archive and volume-group backups in /etc/lvm/backup, but those files are recovery material, not permission to run vgcfgrestore blindly. A restore can change metadata and must be planned against the affected devices.

For a read-only hand-off, save the outputs of lvm version, lvmconfig --type diff, pvs, vgs and lvs with the time and host name. That gives the next operator both the software version and the storage view that informed the decision.

Done means

  • You know the installed LVM2 version and have recorded any non-root warning.
  • You have inspected PV, VG and LV state without running a storage-changing command.
  • You have checked effective and non-default configuration with lvmconfig.
  • You can identify whether a setting comes from a command profile, metadata profile, tag, local file or main configuration file.
  • Any future destructive operation has its own command manual page, backup or recovery plan, and maintenance window.