LVM reports "Cannot use device with duplicates."

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8

Issue

  • When attempting to extend a VG, the below error is produced:
# vgextend example_vg /dev/mapper/mpatha
  Error vgextend : Cannot use device /dev/mapper/mpatha with duplicates.
  WARNING: Not using lvmetad because duplicate PVs were found.
  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?
  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.
  WARNING: PV xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxx on /dev/sdx was already found on /dev/sdy.
  WARNING: PV xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxx on /dev/sdy was already found on /dev/sdz.
  WARNING: PV xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxx on /dev/sdz was already found on /dev/mapper/mpatha.
<...>
 Cannot use device /dev/mapper/mpatha with duplicates.
  • When attempting to create a new volume group, getting error Cannot use device /dev/mapper/mpatha with duplicates.

Resolution

  • A custom filter will need to be set in /etc/lvm/lvm.conf, including the global filter.

  • Example from /etc/lvm/lvm.conf:

    filter = [ "a|^/dev/sda5$|", "a|/dev/emcpower.*|", "r|.*|" ]
    global_filter = [ "a|^/dev/sda5$|, "a|/dev/emcpower.*|", "r|.*|" ]
  • Once the filter is in place, the initramfs will need to be rebuilt. Then update the LVM cache and attempt to execute the vgextend command again.
        # cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date +%m-%d-%H%M%S).bak
        # dracut -f -v
        # pvscan --cache

Root Cause

  • If there isn't a filter in place, then the lvm.conf file will default to accept all devices:
    # This configuration option has an automatic default value.
    # filter = [ "a|.*/|" ]

Diagnostic Steps

  • Check /etc/lvm/lvm.conf for filters
        # Example
        # Accept every block device:
        #filter = [ "a|.*/|" ]
        # Reject the cdrom drive:
        # filter = [ "r|/dev/cdrom|" ]
        # Work with just loopback devices, e.g. for testing:
        # filter = [ "a|loop|", "r|.*|" ]
        # Accept all loop devices and ide drives except hdc:
        # filter = [ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ]
        # Use anchors to be very specific:
        # filter = [ "a|^/dev/hda8$|", "r|.*/|" ]
        # 
        # This configuration option has an automatic default value.
        # filter = [ "a|.*/|" ]

        # Configuration option devices/global_filter.
        # Limit the block devices that are used by LVM system components.
        # Because devices/filter may be overridden from the command line, it is
        # not suitable for system-wide device filtering, e.g. udev and lvmetad.
        # Use global_filter to hide devices from these LVM system components.
        # The syntax is the same as devices/filter. Devices rejected by
        # global_filter are not opened by LVM.
        # This configuration option has an automatic default value.
        # global_filter = [ "a|.*/|" ]
  • If the default filter is set, change to filter to match your system's configuration
        filter = [ "a|^/dev/sda5$|", "a|/dev/emcpower.*|", "r|.*|" ]
        global_filter = [ "a|^/dev/sda5$|, "a|/dev/emcpower.*|", "r|.*|" ]

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments