|

LVM PV not visible after storage migration

TL;DR: Import block devices to LVM is now required

I perform OS copies between Linux machines once in a while. The process usually involves a source system and a temporary LiveCD (or an installation image in rescue mode).

This process includes creating the new disk layout – partitions, LVs, filesystems, and mounts – on the temporary OS. Later, the cloned system uses that same layout.

On modern Red Hat-flavored Linux distributions, I use LVM whenever possible. However, the new cloned OS may not automatically recognize the LVM physical volumes (PVs).

Running ‘pvs’ or ‘vgs’ results in empty output, even though the root (‘/’) uses LVM and is mounted.

The reason is the use_devicesfile setting in /etc/lvm/lvm.conf. RHEL 9 and newer versions enable the LVM system.devices mechanism by default. This mechanism controls which devices LVM can see and use.

I try to avoid changing defaults on modern operating systems unless I have to.

When using RHEL/OEL 9 and above, you should import unknown PVs into the OS if use_devicesfile remains enabled. This is especially relevant when you move existing LVM storage to a different system.

The same applies to OS migrations, such as:

tar on the source OS → netcat/socat → RAW stream → netcat/socat → tar on the destination temporary OS.

It also applies to LUN migration between hosts and other cases involving foreign LVM storage on modern Linux platforms.

Import the device with lvmdevices

The solution is to run:

lvmdevices --adddev $DEV

This adds the device, or multipath device, to the LVM devices file:

/etc/lvm/devices/system.devices

Once the device appears in system.devices, LVM can see and use the PV. Red Hat specifically documents lvmdevices --adddev as a method for adding devices to this file.

It can also prevent a delayed OS boot when LVM waits for devices that aren’t included in the devices file.

Why can the cloned OS still boot?

In many cases, a cloned system will still boot the OS (/) because the initramfs enforces this mechanism less strictly. This can make the problem particularly confusing: the root filesystem works, but pvs and vgs show nothing.

This behavior applies to / only. Other LVM filesystems can still cause problems.

Reverting to the legacy LVM behavior

You can revert to the older behavior by setting:

use_devicesfile = 0

in /etc/lvm/lvm.conf.

I generally prefer not to change this default unless there is a good reason. Disabling the devices file also switches LVM back to using the device filter.

After changing the LVM configuration, you also need to rebuild the initramfs.

Last words

This represents a significant change in LVM behavior compared with RHEL/OEL 8.

I tripped over it several times when cloning operating systems and moving LVM storage between hosts. The behavior is especially confusing when the PV clearly exists and the root filesystem works, but LVM commands don’t show it.

The important thing to remember is that a block device can exist on the system without LVM being allowed to use it.

When importing foreign LVM storage on RHEL 9, Oracle Linux 9, Rocky Linux 9, and newer systems, check the LVM devices file if the PV doesn’t appear.

In most cases, lvmdevices --adddev is all that is needed to make the device available to LVM. Red Hat also documents vgimportdevices for importing all devices belonging to an existing volume group.

Red Hat’s article is a good reference for this behavior. You can read it here (subscription required).

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.